Backup Docker volumes
Topic: Containers core
Summary
Back up a volume with a temp container that mounts the volume and tars to backup location. Restore by mounting volume and extracting. Use when you need to preserve volume data.
Intent: How-to
Quick answer
- Backup with container that mounts volume and backup dir. tar czf from volume to backup.
- Restore with container that mounts volume and backup. tar xzf into volume.
- Quiesce app for consistency. Test restore on copy.
Prerequisites
Steps
-
Backup
Run container with volume and backup dir. tar volume to backup file. Use --rm.
-
Restore
Run container with volume and backup dir. Extract tar into volume.
-
Verify
Start app. Confirm data. Test restore on new volume.
Summary
Back up volume with tar in one-off container. Restore by extracting. Test restore.
Prerequisites
Steps
Step 1: Backup
Mount volume and backup dir; tar volume to file.
Step 2: Restore
Mount volume and backup; extract into volume.
Step 3: Verify
Start app; confirm data; test restore.
Verification
- Backup exists; restore works.
Troubleshooting
Inconsistent — Quiesce app or use DB dump. Restore fails — Check paths and permissions.