From dc8cf8ecb09987d089dbe64f057290c0be5bcda7 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Mon, 21 Mar 2022 18:37:43 +0100 Subject: [PATCH] Add docs for preparing import from prod --- docs/clean-up-prod-db-for-import.md | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/clean-up-prod-db-for-import.md diff --git a/docs/clean-up-prod-db-for-import.md b/docs/clean-up-prod-db-for-import.md new file mode 100644 index 00000000..c5166779 --- /dev/null +++ b/docs/clean-up-prod-db-for-import.md @@ -0,0 +1,32 @@ +Remove all users that are not admin users, also their created contents +``` +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).delete() +``` + +Make local dump of database + +``` +./scripts/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://bucket-name/dump.name +``` + +Load backup in heroku + +``` +heroku pg:backups:restore --app skillbox-preprod 'SIGNED URL' DATABASE_URL +```