diff --git a/backup.sh b/backup.sh index 4809798..481044e 100755 --- a/backup.sh +++ b/backup.sh @@ -1,8 +1,11 @@ #!/bin/bash +# get script dir path +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + # backup directory -backupDir=./backup +backupDir="${SCRIPT_DIR}/backup" # current date currentDate=$(date +"%Y-%m-%d_%H-%M-%S") @@ -32,10 +35,16 @@ fi +# get compose project name to backup data from correct container +source ${SCRIPT_DIR}/gitbucket.conf +CMPS_PRJ=$(echo $COMPOSE_PROJECT_NAME | tr -cd "[A-Za-z-_]") +echo "backup files from ${CMPS_PRJ} project" + + function backup() { - IDmain=$(docker ps -qf name=main-gitbucket) - IDdb=$(docker ps -qf name=mysql-gitbucket) + IDmain=$(docker ps -qf name=${CMPS_PRJ}_main-gitbucket) + IDdb=$(docker ps -qf name=${CMPS_PRJ}_mysql-gitbucket) while (( "$#" )); do case "$1" in @@ -109,7 +118,7 @@ exit 1 fi - IDmain=$(docker ps -qf name=main-gitbucket) + IDmain=$(docker ps -qf name=${CMPS_PRJ}_main-gitbucket) echo "restore ssh keys" docker cp "${backupDir}/gitbucket.ser" ${IDmain}:/srv/gitbucket/gitbucket.ser diff --git a/gitbucket.conf.example b/gitbucket.conf.example index b92867f..eb5378f 100644 --- a/gitbucket.conf.example +++ b/gitbucket.conf.example @@ -35,3 +35,8 @@ # Timezone one of /usr/share/zoneinfo TZ=Europe/Berlin + + +## compose project name +# this have to be unique for more then one gitbucket instance per docker host +COMPOSE_PROJECT_NAME=gitbucket