notes: add commands to backup and restore volumes

This commit is contained in:
Dmitriy Pleshevskiy 2023-03-24 10:36:58 +03:00
parent 070bd495b6
commit 277f1ed28a
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985

21
notes/docker.md Normal file
View file

@ -0,0 +1,21 @@
# 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"
```