# 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" ``` # Clean overlay2 folder ```sh docker image ls --all --format "{{.ID}}" | xargs -n1 docker inspect | egrep '"Id"|/merged' ``` You'll see something like the following: ``` "Id": "sha256:f8fa7183309d043e93c78224f93e8bce028be5ac331b994e3f3654b8980e7d61", "MergedDir": "/var/lib/docker/overlay2/8eb1a12796c337c8a60f00d6721c26a0dd7ceba66f28f3a66be0cb5b08505561/merged", ``` And now it safe to remove merged dir ```sh rm -rf /var/lib/docker/overlay2/8eb1a12796c337c8a60f00d6721c26a0dd7ceba66f28f3a66be0cb5b08505561 ```