Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Docker Docker & Containers: From Zero to Production Docker Volumes Module 4 — Volumes and Data operations

Backup and Restore Container Data — Practical Guide

Reviewed & accurate
AI Summary

What You'll Learn

Beginner

  • How to back up Docker volumes
  • How to restore from backup
  • How to automate backups
Terminalbash
# Back up a volume
docker run --rm -v pg-data:/data:ro -v $(pwd):/backup alpine tar czf /backup/backup.tar.gz -C /data .

# Restore
docker volume create pg-restored
docker run --rm -v pg-restored:/data -v $(pwd):/backup alpine tar xzf /backup/backup.tar.gz -C /data
Database backup
Use pg_dump/mysqldump for databases, not file-level backups.
Back up with tar inside a temporary container.Restore by extracting into a new volume.Use native DB tools for database backups.

Key Takeaways

  • T
  • e
  • s
  • t
  • y
  • o
  • u
  • r
  • b
  • a
  • c
  • k
  • u
  • p
  • s
  • b
  • y
  • r
  • e
  • s
  • t
  • o
  • r
  • i
  • n
  • g
  • t
  • h
  • e
  • m
  • .
Previously: Lesson 25 covered volume management.
Today: You learned: Back up and restore Docker volumes safely.
Next: Lesson 27 covers sharing data.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments