zeus
3 years ago
3 changed files with 63 additions and 0 deletions
@ -0,0 +1 @@ |
|||||
|
Here you can see all backups |
@ -0,0 +1,58 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
|
||||
|
|
||||
|
SOURCE="${BASH_SOURCE[0]}" |
||||
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
||||
|
TARGET="$(readlink "$SOURCE")" |
||||
|
if [[ $TARGET == /* ]]; then |
||||
|
SOURCE="$TARGET" |
||||
|
else |
||||
|
DIR="$( dirname "$SOURCE" )" |
||||
|
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
SRPATH="$( dirname "$SOURCE" )" |
||||
|
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
||||
|
if [ "$SFPATH" != "$SRPATH" ]; then |
||||
|
RDIR=$SRPATH # relativ path directory |
||||
|
fi |
||||
|
|
||||
|
cwdir=$PWD |
||||
|
wdir=$SFPATH |
||||
|
|
||||
|
if [[ $# -eq 0 ]] ; then |
||||
|
echo 'no service' |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
|
||||
|
if [[ -z "$1" ]] ; then |
||||
|
echo 'no service' |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
service=$1 |
||||
|
servicebase=$(echo $service | cut -d'_' -f1) |
||||
|
|
||||
|
#volumetmp=$(docker inspect --format "{{json .Mounts }}" $service | jq .[] | jq '.Destination') |
||||
|
#volumetmp=$(docker inspect --format "{{json .Mounts }}" $service | jq .[] | jq '.Destination .Source' | jq . -s) |
||||
|
# $(docker inspect --format '{{json .Mounts }}' microservice-xelatexthesis_masterservice_1 | jq '.[] | {local: .Source, dest: .Destination}') |
||||
|
|
||||
|
date=$(date '+%Y-%m-%d-%H-%M') |
||||
|
volume=1 |
||||
|
docker inspect --format '{{json .Mounts }}' microservice-xelatexthesis_masterservice_1 | jq -c '.[]' | while IFS=$"\n" read -r line; do |
||||
|
Local=$(echo "$line" | jq -r '.Source') |
||||
|
Dest=$(echo "$line" | jq -r '.Destination') |
||||
|
if [[ $Local == *"$servicebase"* ]]; then |
||||
|
v=v${volume} |
||||
|
docker run --rm --volumes-from $service -v $SFPATH/mybackups:/backup alpine /bin/sh -c "mkdir -p /backup/${service}.${date}; tar -zcvf /backup/${service}.${date}/$v.tar.gz $Dest; echo \"Local:$Local Dest:$Dest\" > /backup/${service}.${date}/$v.info " |
||||
|
((volume++)) |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
Loading…
Reference in new issue