diff --git a/notes/docker.md b/notes/docker.md new file mode 100644 index 0000000..499fb31 --- /dev/null +++ b/notes/docker.md @@ -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" +```