22 lines
398 B
Markdown
22 lines
398 B
Markdown
|
# 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"
|
||
|
```
|