-1

I first tried using heroku addons:add pgbackups but heroku docs say that it has been deprecated. The instead recommended using this command as specified here

PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser  mydb > mydb.dump

But this throws the following error-

'PGPASSWORD' is not recognized as an internal or external command,
 operable program or batch file.

I have already existing data on my local database and want to transfer those data into the heroku database. Any way to make this work or is there some other way?

WutWut
  • 1,204
  • 2
  • 17
  • 31
  • Have you looked into [fixtures](https://docs.djangoproject.com/en/1.8/howto/initial-data/)? You would get your local data into JSON format and write it to a file. Then you can just 'manage.py loaddata fixture_file' – cameron-f Jun 25 '15 at 01:59
  • I used `pg_dump -Fc --no-acl --no-owner -h localh ost -U user mydb > mydb.dump` and it does seem to work. – WutWut Jun 25 '15 at 02:12
  • How about `python manage.py datadump AppName.Model > a_fixture_file.json` This would put your data for the AppName and Model specified into a plain text file. Then you could use that file to `python manage.py loaddata a_fixutre_file.json` on the server. I'm not sure how heroku works, you have a unix command line to work with, right? – cameron-f Jun 25 '15 at 02:44

1 Answers1

1

You could try fixtures

To create the JSON file from your local database:

python manage.py dumpdata > a_fixture_file.json

Take that file to the server. Be sure your server database has the same migrations. Then

python manage.py loaddata a_fixture_file.json
cameron-f
  • 431
  • 1
  • 3
  • 15
  • Heroku recommends using a cloud service like aws s3 or dropbox to load data in the heroku database. The method you mentioned above, how would it load data into the heroku database? – WutWut Jun 25 '15 at 02:59
  • @turtle I'm not sure how heroku works. The method above would use Django's libraries to load the database. In Django1.8 the database will be specified in the settings.py file and looks like `DATABASE = {'default':{...}}`. On heroku, what does settings.py file set DATABASE as? – cameron-f Jun 25 '15 at 03:23