Smart Manoj
Smart Manoj

Reputation: 5824

Can't import to Heroku Postgres with aws

C:\Users\krishnava\Downloads\git>heroku pg:backups:restore "https://s3.amazonaws.com/backup_xxx"

DATABASE_URL ! WARNING: Destructive Action ! This command will affect the app gcesalem ! To proceed, type gcesalem or re-run this command with --confirm appname

> appname
Starting restore of https://s3.amazonaws.com/backup_xxx

to postgresql-round-xxx... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue restoring.
Use heroku pg:backups to check progress.
Stop a running restore with heroku pg:backups:cancel.

Restoring... !
 !    An error occurred and the backup did not finish.
 !
 !    waiting for restore to complete
 !    pg_restore finished with errors
 !    waiting for download to complete
 !    download finished with errors
 !    please check the source URL and ensure it is publicly accessible
 !
 !    Run heroku pg:backups:info r006 for more details.

Info

 C:\Users\krishnava\Downloads\git>heroku pg:backups:info r006
 === Backup r006
 Database:         BACKUP
 Started at:       2019-07-16 15:34:40 +0000
 Finished at:      2019-07-16 15:34:40 +0000
 Status:           Failed
 Type:             Manual
 Backup Size:      0.00B (0% compression)
 
 === Backup Logs
 2019-07-16 15:34:40 +0000 pg_restore: [archiver] did not find magic string in file header
 2019-07-16 15:34:40 +0000 waiting for restore to complete
 2019-07-16 15:34:40 +0000 pg_restore finished with errors
 2019-07-16 15:34:40 +0000 waiting for download to complete
 2019-07-16 15:34:40 +0000 download finished with errors
 2019-07-16 15:34:40 +0000 please check the source URL and ensure it is publicly accessible- - 

Upvotes: 1

Views: 569

Answers (1)

NavaneethaKrishnan
NavaneethaKrishnan

Reputation: 1318

Instead of doing like this, You can export a copy of the local database and import it to Heroku.

For export from local database,

pg_dump <DATABASE_NAME> > <FILENAME>.sql 

This will ask you to enter your database password. But in Windows, this will ask the User password, because the default user name is the system user name. For this you have to specify your username

pg_dump -U <USER_NAME> <DATABASE_NAME> > <FILENAME>.sql 

For your case the command will be like this:

pg_dump -U postgres gce > gce.sql 

After exporting the local database, you can upload this directly to heruko.

heroku pg:psql --app <APP_NAME> < gce.sql

Upvotes: 2

Related Questions