-
Notifications
You must be signed in to change notification settings - Fork 15
Local Development: Import database dump into local env
Michael Harrison edited this page Dec 9, 2020
·
1 revision
1. Request a new database backup from DevOps. They will likely stick this into your home directory and you’ll need to get this to your local machine.
Depending on how your SSH to Bastion2 is setup, this might work differently. The file might also be in a different directory on the remote server.
scp -i ~/.ssh/id_rsa.pub user@bastion2.cnx.org:/tmp/oscms_prodcms.plsql.xz .
OR
scp openstax:/tmp/oscms_prodcms.plsql.xz .
2. You’ll need to create the new database. If you already have one, you can remove it or rename it. From the psql command prompt:
CREATE DATABASE oscms_prodcms;
OR
ALTER DATABASE oscms_prodcms RENAME TO cms_bk;
3. The file format is likely oscms_prodcms.plsql.xz - so you’ll need to uncompress it. You can uncompress it and pipe it to the psql command with the database name created in the previous step.
xzcat oscms_prodcms.plsql.xz| psql oscms_prodcms
Python manage.py migrate
5. Create your new superuser (must be different than your production user - or whatever env database you are using)
Python manage.py createsuperuser