From 277f1ed28a98d89a6bef7f10b2207baeb33c8cfe Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 24 Mar 2023 10:36:58 +0300 Subject: [PATCH] notes: add commands to backup and restore volumes --- notes/docker.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 notes/docker.md 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" +```