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
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.
Hint
"$PWD" means this folder. Keep the quotes.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.
Hint
Same helper box. Swap the folders: the bag is in /from now.Check
Good backup habit, or not?
Swipe right for good, left for needs work. Or use the buttons.
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.
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
docker run --rm -v practice-data:/from -v "$PWD":/to alpine:3.22 tar czf /to/backup.tar.gz -C /from .docker run --rm -v practice-copy:/to -v "$PWD":/from alpine:3.22 tar xzf /from/backup.tar.gz -C /todocker run --rm -v practice-copy:/data alpine:3.22 ls -la /data
0 of 3 steps done · Your ticks are saved.
Bahasa Melayu
Laptop anda makin lama. Pesanan ada dalam loker kedai-data, jauh dalam folder Docker. Di Docker Desktop, ia tersorok dalam VM Linux. Macam mana nak salin keluar?
Backup (salinan sandaran) bungkus seluruh loker dalam satu beg di rak anda. Satu bekas pembantu yang kecil buat kerja ini, lalu pergi. Tekan kepingan ikut urutan.
Sandarkan kedai-data ke dalam backup.tar.gz, dalam folder ini.
"$PWD" maksudnya folder ini. Kekalkan tanda petik.Untuk pulihkan, anda buka beg itu ke dalam loker. Huruf tar yang mana?
Laptop baru! Loker itu dah tiada. Tinggal backup.tar.gz sahaja. Buka ke dalam loker kedai-data yang baru.
Tabiat backup yang baik, atau tidak?
Kini anda boleh sandarkan volume dan pulihkannya.
You finished this before. Practice is always welcome!
Official docs: Docker docs: Back up, restore, or migrate volumes · Docker docs: docker volume inspect · PostgreSQL: pg_dump
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?