tlaanemaa / backup-docker

A simple command line tool to backup and restore docker containers along with their volumes
Apache License 2.0
65 stars 8 forks source link
backup docker inspect restore volume

backup-docker

Node.js CI Coverage Status

A simple command line tool to backup and restore docker container inspection results and their volumes

The main idea of this package is to make backing up and restoring docker containers as easy as possible while avoiding backing up information that we can easily reproduce. This is achieved by backing up only the container's inspection files and the contents of their volumes. The inspection files can then be later used to recreate the same container, with the same settings, and the volume backups can be used to restore the contents of that container's volumes. This way we can have a backup of everything we would need to restore the container, while not bloating our backup files. All this of course assumes that the image is backed up elsewhere, as it usually is, like in a separate repository or DockerHub.

Installation

Requires node.js v8.0 or later

npm install -g backup-docker

Usage

There are 2 main commands:

When run, two directories are created if not already present in the target directory (defaults to current working directory):

When run with restore command, backup-docker will expect these folders to exist in the target directory, if they don't, it will create them

By default, backup-docker will not backup non-persistent volumes (unnamed) and contents of NFS volumes. This is because it is assumed, that non-persistent volumes don't contain anything worth backing up and NFS volumes are already backed up by whoever is hosting them. This can be altered with the --non-persistent-volumes and --nfs-volume-contents flags.

Examples

All general options

Backup specific options