diff --git a/backup.sh b/backup.sh old mode 100644 new mode 100755 index 9c0a8e7..2081afd --- a/backup.sh +++ b/backup.sh @@ -1,11 +1,9 @@ -#!/bin/bash - # backup each night # param $1 path to town name # param $2 tribe name # param $3 mainfolder that contain folderlist store this in tribe/backup/mainfolder.ter.gz # param $4 prefix special keyword dayname is convert to $(date +%A) -# param $5 folderlist split by a space in doublequote "folder1 folder2" +# param $5 folderlist split by a space in doublequote "folder1 folder2" if "*" or empty then backup the full mainfolder # # Exemple: # For setup @@ -19,19 +17,28 @@ # add in crontab each day at 2h10 with echo "10 2 * * ${pathtown}/${town}/adminapi/backup.sh ${pathtown}/${town} ${tribe} objects $(date +A%) \"list of object to backup\"" | crontab - # add it for setup at least -pathtown=$1 -tribe=$2 -mainfolder=$3 -prefix=$4 -if [ "$prefix" = "dayname" ]; then +pathtown="$1" +tribe="$2" +mainfolder="$3" +prefix="$4" +if [[ "$prefix" == "dayname" ]]; then prefix=$(date +%A) fi folderlist=$5 -# setup adminapi/objects -declare -a folders=($folderlist) -cd ${pathtown} -lstfile="" -for folder in "${folders[@]}"; do - lstfile="${lstfile} ${tribe}/${mainfolder}/${folder}" -done -tar -czf ${tribe}/backups/${prefix}.${mainfolder}.tar.gz ${lstfile} + +if [[ "$folderlist" == "*" || -z "$folderlist" ]]; then + lstfile="${tribe}/${mainfolder}" +else + lstfile="" + for folder in ${folderlist}; do + lstfile="${lstfile} ${tribe}/${mainfolder}/${folder}" + done +fi +cd "$pathtown" +tar -czf "${tribe}/backups/${prefix}.${mainfolder}.tar.gz" "$lstfile" + +if [ $? -eq 0 ]; then + echo "Archive created successfully ${tribe}/backups/${prefix}.${mainfolder}.tar.gz" +else + echo "Error creating archive ${tribe}/backups/${prefix}.${mainfolder}.tar.gz" +fi diff --git a/setup.sh b/setup.sh deleted file mode 100755 index a7a47f6..0000000 --- a/setup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# Installation process -# Create in apxtowns a town-nations -# wget https://{url of an existing apxtri}/setup.sh -# chmode +x setup.sh -# ./setup.sh mode(dev|prod) url() ) -# -mode=$1 -url=$2 - -git clone https://gitea.ndda.fr/apxtri/adminapi -#wget https://testwall-ants.ndda.fr/adminapi/setup.apxtri.tar.gz -wget https://testwall-ants.ndda.fr/adminapi/setup.objects.tar.gz -tar -xzvf setup.objects.tar.gz -C . -p && rm setup.objects.tar.gz -mkdir -p adminapi/objects/persons/{itm,idx} -mkdir -p adminapi/{tmp,logs} -mkdir adminapi/logs/nginx -cd adminapi -yarn install -yarn dev \ No newline at end of file