dotfiles/bin/dvrestore

21 lines
574 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
# https://stackoverflow.com/questions/26331651/how-can-i-backup-a-docker-container-with-its-data-volumes/26339869#26339869
# This script allows you to restore a single volume from a container
# Data in restored in volume with same backupped path
CONTAINER_NAME=$1
VOLUME_NAME=$2
usage() {
echo "Usage: $0 [container name]"
exit 1
}
if [ -z $NEW_CONTAINER_NAME ]
then
echo "Error: missing container name parameter."
usage
fi
sudo docker run -rm --volumes-from $CONTAINER_NAME -v $(pwd):/backup busybox tar xvf /backup/$CONTAINER_NAME_$VOLUME_NAME.tar