Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore a remote dump to RDS

I know how to restore a pg dump into a RDS database if that dump is in my machine, but how could I do it when the dump is available at a remote location, say Amazon S3?

What I want to do is something like this:

pg_restore -h somedomain.us-east-1.rds.amazonaws.com -p 5432 -d databasename -U username https://s3.amazonaws.com/database.dump

But of course this results in

pg_restore: [archiver] could not open input file "https://s3.amazonaws.com/database.dump"

Thanks for your help!

like image 526
sauronnikko Avatar asked Dec 07 '15 17:12

sauronnikko


People also ask

How do I import a dump file into AWS RDS?

Place the dump file in an Amazon S3 bucket. Download the dump file from the Amazon S3 bucket to the DATA_PUMP_DIR directory on the target RDS for Oracle DB instance. Import the data from the copied dump file into the RDS for Oracle DB instance using the package DBMS_DATAPUMP .

How do I restore AWS backup RDS?

In the top right corner of the Amazon RDS console, choose the AWS Region in which to create your DB instance. Choose the same AWS Region as the Amazon S3 bucket that contains your database backup. In the navigation pane, choose Databases. Choose Restore from S3.

How do I restore an RDS snapshot to an existing instance?

To restore a DB instance from a DB snapshotSign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/ . In the navigation pane, choose Snapshots. Choose the DB snapshot that you want to restore from. For Actions, choose Restore snapshot.


1 Answers

If a filename is not specified, pg_restore will take data from standard input (doc). So, this would work:

wget -O - 'https://s3.amazonaws.com/database.dump' | pg_restore -h somedomain.us-east-1.rds.amazonaws.com -p 5432 -d databasename -U username

Note that you can create an RDS snapshot, then create a new DB instance from that snapshot (doc). In your particular situation, I don't know if that would work better than backing up to S3, but it's worth mentioning.

like image 61
Travis Avatar answered Sep 22 '22 21:09

Travis