World map

 

BM: Baca dalam Bahasa Melayu

World D3: Lockers & Phone Lines

Back up and restore a volume

You will learn: to copy a volume into one file on your laptop, and to bring it back.

Checked with Docker Engine 29 on 31 Oct 2026

The problem

docker volume ls shows kedai-data. Its mountpoint is /var/lib/docker/volumes/kedai-data/_data, deep inside Docker's own folder. Docker transcript: $ docker volume ls DRIVER VOLUME NAME local kedai-data $ docker volume inspect -f "{{.Mountpoint}}" kedai-data [ { "CreatedAt": "2026-10-31T01:00:03Z", "Driver": "local", "Labels": null, "Mountpoint": "/var/lib/docker/volumes/kedai-data/_data", "Name": "kedai-data", "Options": null, "Scope": "local" } ]

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB

Lockers (volumes)

  • kedai-data2 files

0 containers (0 running), 1 images, 1 lockers.

Your laptop is getting old. The orders sit in the kedai-data locker, deep in Docker’s own folder. On Docker Desktop, it hides inside a Linux VM. How do you copy it out?

Watch

A backup packs the whole locker into one bag on your shelf. A tiny helper box does it, then leaves. Tap the pieces in order.

Tap the pieces in the right order.

…

Try it

Back up kedai-data into backup.tar.gz, in this folder.

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB

Lockers (volumes)

  • kedai-data2 files

0 containers (0 running), 1 images, 1 lockers.

Predict

To restore, you unpack the bag into a locker. Which tar letters?

Pick one answer.

Try it

New laptop! The locker is gone. Only backup.tar.gz is left. Unpack it into a new kedai-data locker.

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB

0 containers (0 running), 1 images, 0 lockers.

Check

Good backup habit, or not?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4

Keep a copy of the bag off this laptop.

Keep a copy of the bag off this laptop.

You did it!

You can now back up a volume and restore it.

Go deeper (optional)

For Postgres, pg_dump saves the data safely while it runs. --volumes-from db borrows every locker of db, which is handy for backups.

With v added, tar lists every file it packs: ./, ./menu/, ./menu/drinks.txt, ./orders.txt. Docker transcript: $ docker run --rm -v kedai-data:/from -v "$PWD":/to alpine:3.22 tar czvf /to/backup.tar.gz -C /from . ./ ./menu/ ./menu/drinks.txt ./orders.txt

Your laptop~

  • No open hatches

Lunchboxes (containers)

  • No containers yet

Frozen packs (images)

  • alpine:3.221 layers · 12.9MB

Lockers (volumes)

  • kedai-data2 files

0 containers (0 running), 1 images, 1 lockers.

Real rep (optional):

Real mission

  1. docker run --rm -v practice-data:/from -v "$PWD":/to alpine:3.22 tar czf /to/backup.tar.gz -C /from .
  2. docker run --rm -v practice-copy:/to -v "$PWD":/from alpine:3.22 tar xzf /from/backup.tar.gz -C /to
  3. docker run --rm -v practice-copy:/data alpine:3.22 ls -la /data

0 of 3 steps done · Your ticks are saved.