summaryrefslogtreecommitdiff
path: root/docker_tools/docker_restore_vol.sh
blob: 5be6a12c85a7a3487a28ea83ff0a8779b52d35d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

# Please read the README.md distributed along this script

if [ "$#" -ne 2 ]; then

    echo ""
    echo "-----------------------------------------"
    echo "Usage: $0 [source-archive] [target-volume]"
    echo ""
    echo "This will un-tar the [source-archive] to a NEW docker [target-volume]"
    echo "-----------------------------------------"
    echo ""

    exit
fi

echo resotring archive: $1 to data-volume $2

VOLS=`docker volume ls --format '{{.Name}}'`

for v in $VOLS; do

	if [ "$v" == "$2" ]; then
	    echo "volume $v already exists! Bailing out..."
	    exit
	fi

done

docker run --rm -it -v `pwd`:/IN -v $2:/OUT bash tar -C /OUT -xf /IN/$1