Backups
Cutover Instructions
Start one shell connected as the admin RDS user
inv pod.debian
apt update && apt install postgresql-client -y
export DATABASE_URL=...
psql $DATABASE_URL
inv pod.debian --debian-flavor <bullseye:buster:stretch>
.
Run once replicas are scaled down:
DROP DATABASE mywebapp_production;
CREATE DATABASE mywebapp_production;
-- Connect to recreated DB and create extensions if needed
\c mywebapp_production;
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS hstore;
Restore instructions (kubectl)
# scale down (to release DB connections) and drop DB above
kubectl -n mywebapp-production scale deployment/app --replicas=0
# scale back up
kubectl -n mywebapp-production scale deployment/app --replicas=2
# restore DB
inv production pod.restore-db-from-dump --db-var="DATABASE_URL" --filename=mywebapp-archive.dump
NOTE:
If your stack has celery installed then you will need to scale those down as well to free resources:
Restore instructions (invoke-kubesae)
As of version 0.0.21
invoke-kubesae, has a utility command utils.scale-app
to help with this.
Usage Examples
> inv staging utils.scale-app --down # Scales the containers to 0.
> inv staging utils.scale-app --down --celery # Scales the containers, celery-worker, and celery-beat to 0.
> inv staging utils.scale-app # Scales the containers to 2.
> inv staging utils.scale-app --celery # Scales the containers to 2, and celery-worker/celery-beat to 1.
> inv staging utils.scale-app --container-count 4 # Scales the containers to 4.
> inv staging utils.scale-app --container-count 4 --celery # Scales the containers to 4, and celery-worker/celery-beat to 1.
Post-restore tasks
- Wagtail:
- Update
Site
object with correct domain.
- Update
-
Manually run migrations:
3. Manually create new superuser:kubectl -n mywebapp-production exec -it deploy/app -- python manage.py migrate
kubectl -n mywebapp-production exec -it deploy/app -- python manage.py createsuperuser
Last update:
2024-11-18