You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
3 years ago
|
#!/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 #services name with user
|
||
|
servicedir=$2 # service dir
|
||
|
#servicebase=$(echo $service | cut -d'_' -f1)
|
||
|
|
||
|
instanche4backup="community/${servicedir}"
|
||
|
|
||
|
date=$(date '+%Y-%m-%d-%H-%M')
|
||
|
docker run --rm -v $SFPATH/mybackups:/backup -v $SFPATH/$instanche4backup:/community alpine /bin/sh -c "mkdir -p /backup/${service}; tar -zcvf /backup/${service}/${service}.${date}.tar.gz /community;"
|