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
1 changed files with 21 additions and 0 deletions

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"
```