The importance of backup and recovery really only becomes clear in the face of catastrophic data loss. I’ve got a slick little Padrino app that’s starting to generate traffic (and ad revenue). As such, it would be a real shame if my data got lost and I had to start from scratch.
This is what I’m working with:
It’s the old Compose Version 1 syntax, but what follows should still apply. As with all such compositions, I write database data to a data-only container. Though the data persists apart from the Dockerized Postgres container, it still needs to be running (e.g.,
docker-compose up -d).
Assuming the containers are up and running, the appropriate command looks like this:
Given the composition above, the command I actually execute is this:
At this point, the
db.dump file can be transfered to a remote server through whatever means are appropriate (I set this all up in
capistrano to make it super easy).
Another assumption: a new database is up and running on the remote backup machine (ideally using the same
docker-compose.yml file above).
The restore command looks like this:
The command I execute is this: