Repository navigation
DevOps
Important
Is the production server unreachable? Follow this simple steps:
- See
docker psanddocker compose logs -tf... - Check if it's possible to either:
- create a database back-up with
save-postgres. - use
convert-backup(if the container parkour2-rsnapshot was running, as it should.) Adjust volume inconvert-backup.ymlif you wanted any interval/ time different from the previous day at 00:00,daily.0. (Seemisc/rsnapshot/config/rsnapshot.conffor details!)
- create a database back-up with
- Confirm the database you're about to load is the desired one:
file misc/latest.sqldump. - Restart everything
make prod load-backup. - See that
parkour2-rsnapshotcontainer is running, create one snapshot:docker exec parkour2-rsnapshot rsnapshot halfy.
Note
We are providing a Makefile with rules that wrap some of the common operations that admins and developers would need. Try make -n <rule> to see what's going to be run, and decide/ adjust accordingly.
-
List most common available routines:
make help. -
Instant back-up from running instance:
make save-postgres. Media files are no longer a Docker volume shuttled by amakerule β they live as a plain directory on the host (/root/pk2mediaon the VMs, bind-mounted into the container as./media), so backing them up is just backing up a directory (cp/rsync/whatever host-level approach you use elsewhere). In practice you don't need to do this by hand at all:misc/rsnapshot.ymlalready covers it, since theparkour2-rsnapshotcontainer has that same host directory mounted and includes it in its regular snapshots. -
Turning it off:
make down. Or, without removing containers:make stop. -
Turning it on:
make prod. Or, on staging VM (e.g.parkour-test):make dev. Or, on dev's laptop:make dev-easy. -
Instant SQL restoration to running instance:
make db. Assuming there's a previous SQL back-up (misc/*.sqldumpfile.) -
Instant restoration of media files: no
makerule needed anymore β since media is a plain host directory (/root/pk2media), restoring it is a matter of pointing./mediaat (or copying into) the desired backup copy of that directory, e.g. from theparkour2-rsnapshotcontainer's snapshots.
Note
We have two VMs. First, production (hostname: parkour), and secondly, a staging environment (hostname: parkour-test). In both cases, the directory that holds the repo is ~/parkour2.
-
Re-deploy locally with latest database snapshot:
make import-pgdb dev-easy db. -
Re-deploy in staging VM with latest database snapshot:
make import-pgdb dev db. -
To re-deploy in staging VM with latest database snapshot, while having updated code that entails new migrations, you'd run:
make import-pgdb dev db-migras.- Basically,
db-migrasis a drop-in replacement fordb. It requiresmisc/migras.tar.gz, that can be generated withtar-old-migrasbeforehand, on the code version that matches the production database schema (e.g. on your production VM; or viagit checkout <tag to version number>). - When the code has new migrations compared to the production deployment and its database snapshot, we'll run
db-migraswhich is an alias forput-old-migras db put-new-migras. Theput-old-migrasremoves your migrations and puts in place the ones inmisc/migras.tar.gz, so that the correct database schema is in place when loading the SQL dump. After that, the current migrations are restored and applied, thanks toput-new-migras. - The same chaining could be done for
load-fixturesif because of reasons you were using JSON files instead of SQL dump:put-old-migras load-fixtures put-new-migras...
- Basically,
- Installation
-
Maintenance (DevOps)
- Updating
- Blue/green deployment [new!]
- Cronjobs
- General (or, independent-to-containers)