fix backup and setup sh

This commit is contained in:
philc 2024-10-31 12:05:42 +01:00
parent 675c29b105
commit 40230925f9
2 changed files with 23 additions and 36 deletions

37
backup.sh Normal file → Executable file
View File

@ -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
if [[ "$folderlist" == "*" || -z "$folderlist" ]]; then
lstfile="${tribe}/${mainfolder}"
else
lstfile=""
for folder in ${folderlist}; do
lstfile="${lstfile} ${tribe}/${mainfolder}/${folder}"
done
tar -czf ${tribe}/backups/${prefix}.${mainfolder}.tar.gz ${lstfile}
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

View File

@ -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