Backup a Running Docker Container

Backup a running Docker container?

Posted by one friend in comments

Hi Slava, sorry that your question was closed. For the record, Slava is talking about docker.io, a runtime for linux containers. Yes, docker export is a suitable approach. It will generate a tarball of your entire container filesystem state, and dump it on stdout. So

docker export $CONTAINER_ID > $CONTAINER_ID-backup.tar

will yield a usable tarball. You can re-import the tarball with

docker import - slava/$CONTAINER_ID-backup < $CONTAINER_ID-backup.tar

Note the original metadata (eg id of the original image) will be lost. This should be fixed in future versions of docker.
Solomon Hykes Apr 2 '13 at 6:35

Adding here so one can find from summary that question was answered. Thanks Solomon!

How to backup docker container with data and move to another server?

Docker, for default, stored images, containers, volumes, and other data, into /var/lib/docker, if not customized by the file /etc/docker/daemons.json as explained here.

In order to move all the graph to a new server you should:

  • Stop docker service.
  • Copy data root.
  • Restart docker service.

Regards.

Backup/Restore a dockerized PostgreSQL database


Backup your databases

docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

Restore your databases

cat your_dump.sql | docker exec -i your-db-container psql -U postgres


Related Topics



Leave a reply



Submit