notes: add commands to backup and restore volumes
This commit is contained in:
parent
070bd495b6
commit
277f1ed28a
1 changed files with 21 additions and 0 deletions
21
notes/docker.md
Normal file
21
notes/docker.md
Normal 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"
|
||||
```
|
Loading…
Reference in a new issue