# HG changeset patch # User Goffi # Date 1455887659 -3600 # Node ID 64623a78af2f272d8de1b75fffc03821dfdc883f # Parent 09099ce530da570ca4914f3007eaca0a8ce46870 docker (libervia_cont): backup dir can now be specified on command line or with SAT_CONT_BACKUP_DIR environment variable diff -r 09099ce530da -r 64623a78af2f docker/libervia_cont.sh --- a/docker/libervia_cont.sh Fri Feb 19 14:14:16 2016 +0100 +++ b/docker/libervia_cont.sh Fri Feb 19 14:14:19 2016 +0100 @@ -22,6 +22,7 @@ # environment variables that can be used for configuration: # SAT_CONT_TLS_DIR for TLS certificates directory # SAT_CONT_DOMAIN for the host name +# SAT_CONT_BACKUP_DIR is the directory where tar.gz backup will be written CONTAINERS="prosody sat_pubsub salut sat libervia" @@ -292,11 +293,19 @@ fi ;; BACKUP) + case $# in + 0) SAT_CONT_BACKUP_DIR="$(pwd)";; + 1) SAT_CONT_BACKUP_DIR="$1";; + *) printf "syntaxe is $0 backup [backup_dir_absolute_path]\n[backup_dir_absolute_path] default to current working dir\n" + exit 1 + ;; + esac + SAT_CONT_BACKUP_DIR=$(echo $SAT_CONT_BACKUP_DIR | sed 's%^\/*\|\/*$%\/%g') # we want to be sure that path starts and finishes with "/" filename="sat_data_backup_$(date '+%Y-%m-%d_%H:%M:%S').tar.gz" - printf "backing up data container to $filename\n\n" - docker run --rm $DK_VOLUME -v "$(pwd):/backup" debian:jessie tar zcvf "/backup/$filename" -C / -h volumes + printf "backing up data container to ${SAT_CONT_BACKUP_DIR}${filename}\n\n" + docker run --rm $DK_VOLUME -v "$SAT_CONT_BACKUP_DIR:/backup" debian:jessie tar zcvf "/backup/$filename" -C / -h volumes if [ $? -eq 0 ]; then - printf "\nBackup finished\n" + printf "\nBackup finished and available at ${SAT_CONT_BACKUP_DIR}${filename}\n" else printf "\nBackup Error !\n" exit 1 @@ -304,7 +313,7 @@ ;; RESTORE) if [ $# -ne 1 ]; then - printf "syntaxe is $0 restore [backup_file.tar.gz]\n" + printf "syntaxe is $0 restore \n" exit 1 fi docker run --name $VOLUME_ALIAS $VOLUME_CONT > /dev/null 2>&1