My Docker notebook
https://docs.docker.com/ee/ucp/admin/backups-and-disaster-recovery/#data-managed-by-ucp
REF: https://docs.docker.com/v17.09/datacenter/ucp/2.2/guides/admin/backups-and-disaster-recovery/
UCP maintains data about:
docker config ls
, including Docker EE license and
swarm and client CAsUCP restore recovers the following assets from the backup file:
UCP restore does not include swarm assets such as cluster membership, services, networks, secrets, etc.
There are two ways to restore UCP:
docker/ucp:2.2.4 backup
)# Create a backup, encrypt it, and store it on /tmp/backup.tar
docker container run --log-driver none --rm -i --name ucp -v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp:2.2.4 backup --interactive > /tmp/backup.tar
# Ensure the backup is a valid tar and list its contents.
# In a valid backup file, over 100 files should appear in the list and the `./ucp-node-certs/key.pem`
# file should be present.
tar --list -f /tmp/backup.tar
# Create a backup, encrypt it, and store it on /tmp/backup.tar, with a passhrase
docker container run --log-driver none --rm -i --name ucp -v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp:2.2.4 backup --interactive --passphrase "secret" > /tmp/backup.tar
# Decrypt the backup and list its contents
$ gpg --decrypt /tmp/backup.tar | tar --list
docker/ucp:2.2.4 restore
)To restore an existing UCP installation from a backup, you need to uninstall UCP from the swarm by using the
uninstall-ucp
command.
When restoring, make sure you use the same version of the docker/ucp image that you’ve used to create the backup.
docker container run --rm -i --name ucp -v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp:2.2.4 restore < /tmp/backup.tar
# If the backup file is encrypted with a passphrase, you will need to provide the passphrase to the restore
# operation:
docker container run --rm -i --name ucp -v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp:2.2.4 restore --passphrase "secret" < /tmp/backup.tar
# The restore command may also be invoked in interactive mode, in which case the backup file should be mounted
# to the container rather than streamed through stdin:
docker container run --rm -i --name ucp -v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/backup.tar:/config/backup.tar \
docker/ucp:2.2.4 restore -i
REF: https://docs.docker.com/ee/dtr/admin/disaster-recovery/create-a-backup/
DTR maintains data about:
docker/dtr:2.5.3 backup
)# To perform a backup of a DTR node, run
docker run -i --rm docker/dtr backup [command options] > backup.tar
This command creates a tar file with the contents of the volumes used by DTR, and prints it. You can then use the ‘restore’ command to restore the data from an existing backup.
This command only creates backups of configurations, and image metadata.
This backup contains sensitive information and should be stored securely.
Using the --offline-backup
flag will temporarily shut down the rethinkdb container. You should take the
replica out of your load balancer to avoid downtime.
# Backup image content
sudo tar -cf \
$(dirname $(docker volume inspect --format '' dtr-registry-<replica-id>))
# Backup DTR metadata
# Where:
# - <ucp-url> is the url you use to access UCP.
# - <ucp-username> is the username of a UCP administrator.
# - <replica-id> is the id of the DTR replica to backup.
read -sp 'ucp password: ' UCP_PASSWORD; \
docker run --log-driver none -i --rm \
--env UCP_PASSWORD=$UCP_PASSWORD \
docker/dtr:2.5.3 backup \
--ucp-url <ucp-url> \
--ucp-insecure-tls \
--ucp-username <ucp-username> \
--existing-replica-id <replica-id> > dtr-metadata-backup.tar
# Encrypt the backup, as it contains sensitive information like private keys
# This prompts you for a password to encrypt the backup, copies the backup file and encrypts it.
gpg --symmetric dtr-metadata-backup.tar
# Validate the backup by printing the contents of the tar file created
tar -tf dtr-metadata-backup.tar
> dtr-backup-v2.5.3/
> dtr-backup-v2.5.3/rethink/
> dtr-backup-v2.5.3/rethink/layers/
...
> dtr-backup-v2.5.3/rethink/properties/
> dtr-backup-v2.5.3/rethink/properties/0
# If you’ve encrypted the metadata backup, you can use
gpg -d dtr-metadata-backup.tar | tar -t
You can also create a backup of a UCP cluster and restore it into a new cluster. Then restore DTR on that new cluster to confirm that everything is working as expected.
docker/dtr:2.5.3 restore
)You need to restore DTR on the same UCP cluster where you’ve created the backup.
# Start by removing any DTR container that is still running
docker run -it --rm docker/dtr:2.5.3 destroy --ucp-insecure-tls
# Restore images
# If you had DTR configured to store images on the local filesystem, you can extract your backup:
sudo tar -xf dtr-image-backup.tar -C /var/lib/docker/volumes
# Restore DTR metadata
read -sp 'ucp password: ' UCP_PASSWORD; \
docker run -i --rm \
--env UCP_PASSWORD=$UCP_PASSWORD \
docker/dtr:2.5.3 restore \
--ucp-url <ucp-url> \
--ucp-insecure-tls \
--ucp-username <ucp-username> \
--ucp-node <hostname> \
--replica-id <replica-id> \
--dtr-external-url <dtr-external-url> < dtr-metadata-backup.tar