-
Notifications
You must be signed in to change notification settings - Fork 6
DevOps
Important
Is the production server unreachable? Follow this simple steps:
- See
docker ps
anddocker 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.yml
if you wanted any interval/ time different from the previous day at 00:00,daily.0
. (Seemisc/rsnapshot/config/rsnapshot.conf
for 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-rsnapshot
container 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 save-media
. -
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/*.sqldump
file.) -
Instant restoration of media files:
make load-media
.
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-migras
is a drop-in replacement fordb
. It requiresmisc/migras.tar.gz
, that can be generated withtar-old-migras
beforehand, 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-migras
which is an alias forput-old-migras db put-new-migras
. Theput-old-migras
removes 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-fixtures
if because of reasons you were using JSON files instead of SQL dump:put-old-migras load-fixtures put-new-migras
...
- Basically,