Skip to content

Commit fb215ba

Browse files
committed
document dtr backup/restore better
fix docker#1722
1 parent e295431 commit fb215ba

File tree

1 file changed

+80
-22
lines changed

1 file changed

+80
-22
lines changed

datacenter/dtr/2.2/guides/admin/backups-and-disaster-recovery.md

+80-22
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ keywords: docker, registry, high-availability, backup, recovery
44
title: DTR backups and recovery
55
---
66

7-
When you use Docker Trusted Registry on a production setting, you should first
8-
configure it for high availability.
9-
10-
The next step is creating a backup policy and disaster recovery plan.
7+
DTR relies on consensus to operate and if it loses consensus permanently
8+
and the replica that failed can't be brought back to life, the only
9+
option is to restore from backups. This is why it's very important to perform
10+
periodic backups. Note that backups are tied to specific DTR versions and work
11+
best with those DTR versions. You can backup/restore across patch versions
12+
at your own risk, but not across minor versions as those require more complex
13+
migrations.
1114

1215
## DTR data persistence
1316

@@ -17,6 +20,9 @@ Docker Trusted Registry persists:
1720
that is replicated through all DTR replicas.
1821
* **Repository metadata**: the information about the repositories and
1922
images deployed. This information is replicated through all DTR replicas.
23+
* **Access control**: permissions for teams and repos.
24+
* **Notary data**: notary tags and signatures.
25+
* **Scan results**: security scanning results for images.
2026
* **Certificates and keys**: the certificates, public keys, and private keys
2127
that are used for mutual TLS communication.
2228

@@ -37,17 +43,30 @@ command creates a backup of DTR:
3743

3844
These files are added to a tar archive, and the result is streamed to stdout.
3945

46+
Things DTR's backup command doesn't back up:
47+
48+
* The image scanning database (if using image scanning)
49+
* Image contents
50+
* Users, orgs, teams
51+
52+
There is no way to back up the image scanning database. You can re-download it
53+
after restoring or re-apply your offline tar update if offline.
54+
4055
The backup command does not create a backup of Docker images. You should
4156
implement a separate backup policy for the Docker images, taking in
4257
consideration whether your DTR installation is configured to store images on the
43-
filesystem or using a cloud provider.
58+
filesystem or using a cloud provider. During restore, you need to separately
59+
restore the image contents.
4460

4561
The backup command also doesn't create a backup of the users and organizations.
4662
That data is managed by UCP, so when you create a UCP backup you're creating
47-
a backup of the users and organizations metadata.
63+
a backup of the users and organizations. For this reason, when restoring DTR,
64+
you must do it on the same UCP cluster (or one created by restoring from
65+
backups) or else all DTR resources such as repos will be owned by non-existent
66+
users and will not be usable despite technically existing in the database.
4867

4968
When creating a backup, the resulting .tar file contains sensitive information
50-
like private keys. You should ensure the backups are stored securely.
69+
such as private keys. You should ensure the backups are stored securely.
5170

5271
You can check the
5372
[reference documentation](../../reference/cli/backup.md), for the
@@ -71,34 +90,67 @@ Where:
7190
* `--existing-replica-id` is the id of the replica to backup,
7291
* `--ucp-username`, and `--ucp-password` are the credentials of a UCP administrator.
7392

93+
To avoid having to pass the password as a command line parameter, you may
94+
instead use the following approach in bash:
95+
96+
```none
97+
$ read -sp 'ucp password: ' PASS; UCP_PASSWORD=$PASS docker run -i --rm -e UCP_PASSWORD docker/dtr backup \
98+
--ucp-url <ucp-url> \
99+
--ucp-insecure-tls \
100+
--existing-replica-id <replica-id> \
101+
--ucp-username <ucp-admin> > /tmp/backup.tar
102+
```
103+
104+
This puts the password into a shell variable which is then passed into the
105+
docker client command with the -e flag which in turn relays the password to the
106+
DTR bootstrapper.
107+
108+
## Testing backups
109+
74110
To validate that the backup was correctly performed, you can print the contents
75111
of the tar file created:
76112

77113
```none
78114
$ tar -tf /tmp/backup.tar
79115
```
80116

117+
To really test that the backup works, you must make a copy of your UCP cluster
118+
by backing it up and restoring it onto separate machines. Then you can restore
119+
DTR there from your backup and verify that it has all the data you expect to
120+
see.
121+
81122
## Restore DTR data
82123

83-
You can restore a DTR node from a backup using the `restore`
84-
command.
85-
This command performs a fresh installation of DTR, and reconfigures it with
86-
the configuration created during a backup.
124+
You can restore a DTR node from a backup using the `restore` command.
87125

88-
The command starts by installing DTR, restores the configurations stored on
89-
etcd, and then restores the repository metadata stored on RethinkDB. You
90-
can use the `--config-only` option, to only restore the configurations stored
91-
on etcd.
126+
Before restoring DTR, make sure that you are restoring it on the same UCP
127+
cluster or you've also restored UCP using its restore command. DTR does not
128+
manage users, orgs or teams so if you try to
129+
restore DTR on a cluster other than the one it was backed up on, DTR
130+
repositories will be associated with users that don't exist and it will appear
131+
as if the restore operation didn't work.
92132

93-
This command does not restore Docker images. You should implement a separate
94-
restore procedure for the Docker images stored in your registry, taking in
95-
consideration whether your DTR installation is configured to store images on
96-
the filesystem or using a cloud provider.
133+
Note that to restore DTR, you must first remove any left over containers from
134+
the previous installation.
97135

98-
You can check the
99-
[reference documentation](../../reference/cli/backup.md), for the
100-
backup command to learn about all the available flags.
136+
The restore command performs a fresh installation of DTR, and reconfigures it with
137+
the configuration created during a backup. The command starts by installing DTR,
138+
restores the configurations from the
139+
backup and then restores the repository metadata. All install time flags are the same
140+
for restore and apply the same way they would to a new installation.
141+
142+
After restoring DTR, you must make sure that it's configured to use the same
143+
storage backend where it can find the image data. If the image data was backed
144+
up separately, you must restore it now.
101145

146+
Finally, if you are using security scanning, you must re-fetch the security
147+
scanning database through the online update or by uploading the offline tar. See
148+
the [security scanning configuration](../admin/configure/set-up-vulnerability-scans.md)
149+
for more detail.
150+
151+
You can check the
152+
[reference documentation](../../reference/cli/restore.md), for the
153+
restore command to learn about all the available flags.
102154

103155
As an example, to install DTR on the host and restore its
104156
state from an existing backup:
@@ -121,6 +173,12 @@ Where:
121173
* `--ucp-username`, and `--ucp-password` are the credentials of a UCP administrator,
122174
* `--dtr-load-balancer` is the domain name or ip where DTR can be reached.
123175

176+
Note that if you want to avoid typing your password into the terminal you must pass
177+
it in as an environment variable using the same approach as for the backup command:
178+
179+
```none
180+
$ read -sp 'ucp password: ' PASS; UCP_PASSWORD=$PASS docker run -i --rm -e UCP_PASSWORD docker/dtr restore ...
181+
```
124182

125183
## Where to go next
126184

0 commit comments

Comments
 (0)