1.4 KiB
1.4 KiB
Update prepreprod Database Contents
This document describes the process to import data from a Production database to a preprod database, whith the removal of all users and their content that are not admin users. Checkout the commit that is deployed on your target preprod app.
Download latest backup from Heroku
heroku pg:backups:download --app appname
Load backup locally
assumes your POSTGRES env variables are set correctly
./bin/restore-database.sh -f -d
Remove all users that are not admin users, also their created contents
```bash
pip install shell_plus --upgrade
python mangage.py migrate
python manage.py shell
Objective.objects.exclude(owner=None).delete()
Comment.objects.all().delete()
Assignment.objects.exclude(owner=None).exclude(owner__username="guru").delete()
User.objects.filter(is_superuser=False).exclude(username="mia.teacher@getnada.com").delete()
Make local dump of database
./bin/dump_local_database.sh
Copy local dump to s3 bucket
aws s3 cp local.dump s3://skillbox-developer-bucket/
Get a presigned url from S3 for the dump (supposedly works from the command line, I had to use the S3 web UI)
aws s3 presign s3://skillbox-developer-bucket/local.dump
Load backup in heroku
heroku pg:backups:restore --app skillbox-preprod 'SIGNED URL' DATABASE_URL