是否可以使用AWS Data Pipeline将RDS数据库转储到S3?

Jes*_*ham 5 amazon-s3 rds amazon-web-services aws-cloudformation amazon-data-pipeline

基本上,我想pg_dump使用AWS Data Pipeline 将RDS数据库迁移到S3,

我不是100%不确定这是否可行,我已经站到SqlDataNode想要解决的问题selectQuery上,我想知道该怎么做。

以下是到目前为止的模板:

AWSTemplateFormatVersion: "2010-05-15"

Description: RDS to S3 Dump

Parameters:
  RDSInstanceID:
    Description: "Instance ID of RDS to Dump from"
  DatabaseName:
    Description: "Name of the Database to Dump"
    Type: String
  Username:
    Description: "Database Username"
    Type: String
  Password:
    Description: "Database password"
    Type: String
    NoEcho: true

RDSToS3Dump:
  Type: "AWS::DataPipeline::Pipeline"
  Properties:
    Name: "RDSToS3Dump"
    Description: "Pipeline to backup RDS data to S3"
    Activate: true
    ParameterObjects:
      -
        name: "SourceRDSTable"
        type: "SqlDataNode"
        Database: !Ref DatabaseName
      -
        name: !Ref DatabaseName
        type: "RdsDatabase"
        databaseName: !Ref DatabaseName
        username: !Ref Username
        password: !Ref Password
        rdsInstanceId: !Ref RDSInstanceID
      -
        name: "S3OutputLocation"
        type: "S3DataNode"
        filePath: #TODO: S3 Bucket here parameterized? Will actually need to create one.
      -
        name: "RDStoS3CopyActivity"
        type: "CopyActivity"
        input: "SourceRDSTable"
        output: "S3OutputLocation"
        #TODO: do we need a runsOn?
Run Code Online (Sandbox Code Playgroud)

Adi*_*tya 3

正如另一个答案中提到的,AWS Data Pipeline只允许您转储表,而不是整个数据库。如果您确实想使用pg_dump将数据库的全部内容转储到 S3 AWS CloudFormation,则可以使用Lambda 支持的自定义资源。按照这条路线,您必须编写一个 Lambda 函数:

  • 连接到数据库
  • 使用以下命令转储数据库pg_dump
  • 上传到S3