- [Instructor] In production environments,
it's especially important
to ensure that you have data protection
for your Docker infrastructure.
Backing up Docker involves a backup of four critical pieces.
First off, the Docker swarm cluster,
which I'll show you how to backup in just a moment.
From there you need to backup the universal control plane,
which I'll also show you how to do.
After that, the Docker-trusted registry,
if you're using DTR, and it has a number of different pieces
that need to be protected.
And finally, the container volume data,
wherever you store that data.
To backup the Docker swarm cluster,
you need to go to one of the managers,
stop the Docker service with systemctl stop docker,
CD into var/lib/docker,
copy or archive off the swarm directory,
and then finally, do a systemctl start docker
to restart the Docker services.
Let's go through it at the command line.
We're here on a Docker swarm manager node,
and I'm just going to stop Docker
with the systemctl stop docker command.
Once Docker is stopped, we'll CD to var/lib/docker.
And if we do an ls -l in here,
you can see the swarm directory is located here.
And this is what you would want to copy off
into some sort of temporary location,
for example, into the temp directory.
So we can copy the entire swarm directory,
actually, we need to make sure
we use the right command string there
to go recursively down into the folder,
and we'll copy the swarm directory off
into a temporary folder.
However you choose to protect it is up to you,
you could tar it off, copy it off,
use a data protection tool of some kind,
however you choose to do it,
you just need to make sure that swarm is stopped first,
protect that directory, and then once you're done,
you can restart swarm
with the systemctl start space docker command.
As I mentioned, another critical piece
of the Docker enterprise infrastructure
that you need to protect, is the universal control plane.
Now, Docker offers us specific instructions
for backing up the universal control plane.
In fact, they provide us a very nice backup command
that you can run right here on your system
with a simple copy-and-paste.
This command will take the universal control plane data
and put it into a backup .tar file for you.
I've pasted that to show you how to do this,
we'll copy this command into the command line
over on our UCP manager.
And we're here on a UCP manager.
I'll paste in that command line, press Enter.
It gives us a warning
that we're about to temporarily stop all UCP containers,
so keep in mind, this will bring down the UCP interface,
the swarm cluster will continue to function
and the web applications will stay up.
It's the UCP centralized management interface
that will be unavailable.
We'll say yes, that we want to proceed with the backup,
we'll give this just a moment.
To protect Docker-trusted registry,
there are a couple of different types of data
that you need to take into account.
First off, there's the registry content data.
These are the images that you've stored in DTR.
And Docker provides us a nice tar command
that we can use to backup those images.
The next piece of DTR,
that needs to be protected, is the DTR metadata.
This is the information about those images.
And again, here's another command
that I'll include in the course resources
that runs a DTR's backup container
and outputs that into a backup-metadata.tar file.
And finally, the fourth piece of a Docker enterprise cluster
that you need to protect is your container volume data.
This data should not be inside your containers,
that would violate the best practices
because as you know, containers are ephemeral.
And once a container is removed,
the data inside of that container is also removed.
So that container data, that volume data,
should be stored in a container volume,
and container volumes could be stored locally
on Docker nodes, or on a share
that points to a SAN or a NAS,
in your data center or even up in the public cloud.
So no matter where that data is,
you need to make sure that you protect it.
So those are the four pieces of an enterprise Docker cluster
that you need to protect, the Docker swarm cluster data,
the universal control plane data,
the Docker-trusted registry data,
and the container volume data.