system/notes/docker.md

22 lines
398 B
Markdown
Raw Normal View History

# Backup and restore volumes
Backup a volume
```sh
docker run \
--rm \
--volumes-from source_container_name \
-v $(pwd):/backup \
busybox tar cvf /backup/backup.tar /path/to/volume
```
Restore volume from a backup
```sh
docker run \
--rm \
--volumes-from target_container_name \
-v $(pwd):/backup \
busybox sh -c "cd /path/to/volume && tar xvf /backup/backup.tar --strip 1"
```