Skip to content

Instantly share code, notes, and snippets.

@ineentho
Created March 23, 2020 08:05
Show Gist options
  • Save ineentho/106c09bd847f68e357d1f62e57a867db to your computer and use it in GitHub Desktop.
Save ineentho/106c09bd847f68e357d1f62e57a867db to your computer and use it in GitHub Desktop.
Docker volume backup and restore
#!/bin/sh
vol-backup() {
docker run --rm -v $1:/data -v $(pwd):/backup busybox tar cvf /backup/$1.tar /data
}
vol-restore() {
docker create -v $1:/data --name $1 busybox true
docker run --rm --volumes-from $1 -v $(pwd):/backup busybox tar xvf /backup/$1.tar
docker rm $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment