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

33
backup.sh Normal file → Executable file
View File

@ -1,11 +1,9 @@
#!/bin/bash
# backup each night # backup each night
# param $1 path to town name # param $1 path to town name
# param $2 tribe name # param $2 tribe name
# param $3 mainfolder that contain folderlist store this in tribe/backup/mainfolder.ter.gz # 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 $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: # Exemple:
# For setup # 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 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 # add it for setup at least
pathtown=$1 pathtown="$1"
tribe=$2 tribe="$2"
mainfolder=$3 mainfolder="$3"
prefix=$4 prefix="$4"
if [ "$prefix" = "dayname" ]; then if [[ "$prefix" == "dayname" ]]; then
prefix=$(date +%A) prefix=$(date +%A)
fi fi
folderlist=$5 folderlist=$5
# setup adminapi/objects
declare -a folders=($folderlist) if [[ "$folderlist" == "*" || -z "$folderlist" ]]; then
cd ${pathtown} lstfile="${tribe}/${mainfolder}"
else
lstfile="" lstfile=""
for folder in "${folders[@]}"; do for folder in ${folderlist}; do
lstfile="${lstfile} ${tribe}/${mainfolder}/${folder}" lstfile="${lstfile} ${tribe}/${mainfolder}/${folder}"
done done
tar -czf ${tribe}/backups/${prefix}.${mainfolder}.tar.gz ${lstfile} 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