Can I dump an RDS database to S3 using AWS Data Pipeline?

Basically I want pg_dump

my RDS database on S3 using AWS Data Pipeline,

I'm not 100% sure, if it's possible, I got into the scene where a SqlDataNode

wants selectQuery

, at what point I wonder what to do.

Below is my template:

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?

      

+3


source to share


2 answers


As mentioned in another answer, AWS Data Pipeline allows you to drop tables, not the entire DB. If you really want to use pg_dump

to reset all of your content databases on S3 using AWS CloudFormation

, you can use the Custom resources to support Lambda . Going down that route, you need to write a lambda function that:



  • Connects to DB
  • Receives a dump of your db with pg_dump

  • Uploads it to S3
+3


source


Using Data Pipeline I believe you can drop tables and not the whole db as with pg_dump.

You looked at the docs because selectQuery just requires an SQL statement for what you want to flush, i.e. "select * from my table"? Maybe it helps. http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-object-sqldatanode.html



  -
    name: "SourceRDSTable"
    type: "SqlDataNode"
    Database: !Ref DatabaseName
    table: "mytable"
    selectQuery: "select * from #{table}"

      

+1


source







All Articles