Hacker News new | ask | show | jobs
by hippiefahrzeug 4270 days ago
There are two ways:

1. You run the db and its files inside a container and regularly export a DB dump like so (example for postgres):

docker run --volumes-from db -v $(pwd):/backup ubuntu:trusty sh -c "cd /var/lib && tar zcvf /backup/backup.tgz postgresql"

(I don't recommend this)

2. You run the db inside a docker container and mount a volume for /var/lib/postgresql into docker. This I find is the best way. the db files remain on your host and you can easily maintain the DB (runtime) and files separately.

Adjust to whatever DB you're using.