


If everything checks out, then you will be able to see the same dummy content, log in with the same email and password. $ docker run -d -v my-volume-2:/var/lib/ghost/content -p 80:2368 ghost:latest $ docker run -rm -v my-volume-2:/recover -v ~/backup:/backup ubuntu bash -c “cd /recover & tar xvf /backup/ghost-site.tar” Mounting this volume to the new container Spinning up a temporary container to recover from the tarball into this volume Now, the steps for recovery would involve: Logging into the VPS, let’s delete the container and volume, mimicking a disaster. To begin with, I have the following dummy content on my website:
DUPLICACY DOCKER TRIAL
Let’s do a trial run when things are running fine.
DUPLICACY DOCKER HOW TO
Let’s not wait for a disaster to strike, and then figure out how to restore. You don’t have a backup until you have at least once tried to recover your original data from the backup. This is the same ~/backup/ directory on your host system where a new ghost-site.tar file would appear. Ubuntu: Specifies that the container should run an Ubuntu image.īash -c “.” : Backs up the contents of your website as a tarball inside /backup/ inside the container. v ~/backup:/backup: Bind mount of the ~/backup/ directory from your host to the /backup directory inside the temporary container. The mount points are the same as the original container.

volumes-from ghost-site : Mounts all the volumes from container ghost-site also to this temporary container. rm flag tells Docker to remove the container once it stops.

docker run creates a new container, that much is obvious. $ docker run -rm -volumes-from ghost-site -v ~/backup:/backup ubuntu bash -c “cd /var/lib/ghost/content & tar cvf /backup/ghost-site.tar. Next, we spin up a temporary container with the volume and the backup folder mounted into it. In our example, the main container is ghost-site which uses Docker volume my-volume, mounted at /var/lib/ghost/content, to store all of its data. On the other hand, an e-commerce site can receive an order at any given moment, even when you are running the backup! If that’s the case, then you need to stop the main container before running a backup. If you are running a small blog where you add the content, not your customers, then the answer is most certainly no. Is the data in this volume changing right now? But before you do take a backup, ask yourself this question: The official Docker documentation recommends this behavior, so you know it’s safe to try on your containers and volumes. Bind mounts, unlike Docker volumes, are not exclusively managed by Docker daemons, and hence we can use them as our backup folder. When an ordinary directory like ~/backups is mounted inside a Docker container we call it a bind mount. Get limited-time deals!⚡ Running a Docker volume backupįirst, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container. Score a 16GB Performance VPS with 160GB of NVMe storage for just $99/year for a limited time! There's nothing else like it on the market, at least not at these prices. We DOUBLED the amount of blazing-fast NVMe storage on our most popular plan and beefed up the CPU offering on these plans. Develop at hyperspeed with a Performance VPS from SSD Nodes.
