Search code examples
postgresqlamazon-s3command-linepg-restore

Using pg_restore with a remote file


I'm trying to use pg_restore to restore my database from a remote file stored in an amazon S3 bucket.

I tried to do this : pg_restore -c -d mydb https://myfileURL but it doesn't work, it says there is no such file or directory. The URL is fine, it's just that it can't get the file from it.

Which makes sense somehow but how can I do such a thing then ?

Perhaps there is a way to do something like this : https://myfileURL > dump.tmp and then executing pg_restore with the created file ?

Not sure if it could be a solution but I don't want to use the AWS CLI.


Solution

  • Download the file first:

    wget https://myfileURL -O dump.tmp
    pg_restore -c -d dump.tmp