Skip to main content
To back up a Docker volume, stop the app with docker compose stop, then run a temporary container that mounts the volume and your backup folder and archives it: docker run --rm -v app_data:/data:ro -v ~/backups:/backup alpine:3.24 tar czf /backup/app_data.tar.gz -C /data .. Restore by extracting the archive into a volume the same way. Dump databases with their own tools as well.

Before you start

  • A volume is storage that Docker manages for a container. Named volumes live under /var/lib/docker/volumes/<name>/_data. A bind mount is a normal folder on the server, such as ./data next to compose.yaml.
  • Docker doesn’t back up volumes for you. Removing them with docker compose down -v or docker volume prune -a deletes the data for good.
  • Copying a database’s files while it is running can give you a broken copy. Stop the app first, or dump the database with its own tool.
  • A backup on the same disk doesn’t survive a disk failure or a rebuild. Copy the archives off the server, for example with rclone or restic.

How to find the volumes to back up

Compose names volumes <project>_<volume>. The db volume in the ~/wordpress project from the Docker Compose tutorial is called wordpress_db. "Type":"bind" entries in the inspect output are folders; back those up as normal files.

How to back up a Docker volume

1

Make a backup folder

2

Stop the app

stop keeps the containers and volumes. Don’t use down -v.
3

Archive the volume

The temporary container mounts the volume read-only at /data, writes a compressed archive to ~/backups, and is removed when tar finishes. Repeat for each volume.
4

Start the app again

How to check the backup worked

You see the archive with a sensible size, and tar lists the files inside, starting with ./.

How to restore a Docker volume

1

Stop the app

2

Create the volume if it doesn't exist

On a new server, create it with the exact name Compose expects:
Compose prints a warning that the volume already exists but wasn’t created by Compose. It still uses it.
3

Extract the archive into the volume

4

Start the app

Restoring into a volume that already has data mixes old and new files. To restore cleanly, remove the volume first with docker volume rm wordpress_db (after checking your archive is good), create it again and then extract.

How to back up a database without stopping it

Dump files from the database’s own tool are consistent while the app keeps running, and they restore across versions more reliably than raw files.
Restore with:
The variables come from the container’s own environment. With the mysql image, use mysqldump, mysql and the MYSQL_* variables.
-T turns off the pseudo-terminal so the output goes cleanly into the file. See also back up and restore MySQL databases.

How to back up all volumes every night

Save this as /usr/local/bin/backup-docker-volumes.sh:
Make it executable with sudo chmod +x /usr/local/bin/backup-docker-volumes.sh and add it to root’s crontab (sudo crontab -e):
This archives every volume at 03:15 and keeps seven days. It doesn’t stop the apps, so pair it with database dumps for anything that runs a database. See schedule tasks with cron.

Frequently asked questions

Can I just copy /var/lib/docker/volumes?

You can, as root and with the containers stopped, but the helper container method works whichever disk or data-root Docker uses and gives you one archive per volume. Never copy the whole /var/lib/docker while Docker is running.

How do I move volumes to another server?

Back up each volume, copy the archives and your project folders (with .env) to the new server with rsync or scp, create the volumes there and restore them, then run docker compose up -d.

Does a VPS backup include my Docker volumes?

A whole-server backup or snapshot includes everything on the disk, Docker data too. Still keep app-level backups, because they let you restore one app without rolling back the whole server. See schedule and restore backups.

Why alpine and not ubuntu?

Any image with tar works; Docker’s own example uses ubuntu. alpine is a few megabytes, so it downloads fast.

VPS and dedicated server guides

Every guide in this section.

Update Docker containers

Back up first, then update.

Encrypted backups with restic

Send your archives off the server.

Move Docker data to another disk

Change where Docker stores volumes.

Back up a Linux server

A full backup plan for the whole server.

Checked against the official Docker volumes documentation and the MariaDB container backup guide on 4 November 2026; volume backup, restore and listing commands tested on Ubuntu 24.04 LTS with Docker Engine 29.9.2 (using a local BusyBox image in place of alpine). Commands can differ on other releases.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026