Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

postgresql - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...