Update all new server scripts

This commit is contained in:
2023-09-06 13:56:08 +02:00
parent a7ed28ff02
commit b0310e14c7
18 changed files with 236 additions and 45 deletions

View File

@@ -23,6 +23,7 @@ ccencryptNow() {
File="$1"
BaseKey="$2"
ccrypt -e -f -K"$(Hash2 "${BaseKey}" "${RunDate}")" "${File}"
echo "${RunDate}" > "${File}.info"
}
WriteLastLog() {

View File

@@ -4,23 +4,43 @@
set -e
. "$(dirname "$(realpath "$0")")/BackupGlobals.cfg"
GitPush() {
GitPush(){
Msg="Auto-Backup $(date) (${RunDate})"
git add . && git commit -m "${Msg}" && git push
}
GitPullPushPath() {
GitPullPushPath(){
BackPath="$(pwd)"
cd "$1" && git pull && GitPush
cd "${BackPath}"
}
BackPathCrypt() {
BackPathCrypt(){
_BackPathCrypt "$1" "$2" "$3"
}
_BackPathCrypt(){
Folder="$1"
Key="$2"
Ext="$([ -z "$3" ] && echo ".tar.xz" || echo "$3")"
cp -v "../${Folder}/Latest${Ext}" "./${Folder}${Ext}" && \
ccencryptNow "./${Folder}${Ext}" "${Key}"
Split="$4"
File="${Folder}${Ext}"
cp -v "../${Folder}/Latest${Ext}" "./${File}" && \
ccencryptNow "./${File}" "${Key}"
#DirContext="${PWD}"
#[ -n "${Split}" ] \
# && mkdir -p "./${File}.cpt.split" \
# && cd "./${File}.cpt.split" \
# && rm * || true \
# && split --bytes="${Split}" "../${File}.cpt" \
# && rm "../${File}.cpt" \
#;
#cd "${DirContext}"
}
BackPathCryptSplit(){
_BackPathCrypt "$1" "$2" "$3" 10M
#...
}
ServerBackupLimited(){
@@ -32,7 +52,7 @@ ServerBackupLimited(){
#BackPathCrypt "shiori-data" "${BackupKey_Git_Shiori}"
BackPathCrypt n8n-data "${BackupKey_Git_n8n}"
# "${BackupKey_Git_aria2}" ".7z"
GitPush
GitPush || true
EchoExec cd ..
}
@@ -40,7 +60,7 @@ ArticlesBackupPrivate(){
EchoExec cd ./Articles-Backup-Private
EchoExec rm -rf ./shiori-data
EchoExec cp -rp "../shiori-data/Latest.d" "./shiori-data"
GitPush
GitPush || true
EchoExec cd ..
}
@@ -55,7 +75,7 @@ DoSpaccBbsBackup(){
./SpaccBBS/arrowchat/includes/config.php \
; do ccencryptNow "$File" "$BackupKey_Git_SpaccBBS"
done
GitPush
GitPush || true
EchoExec cd ..
}
@@ -69,17 +89,17 @@ DoSpaccCraftBackup(){
then
#cd "/Server/${McServer}"
cd "${BackupsBase}/${McServer}"
rm -rf "${DestPath}/${McEdition}"
cp ./*.sh "${DestPath}/"
rm -rf "${DestPath}/${McEdition}" || true
cp ./*.sh "${DestPath}/" || true
cp -r "./${McEdition}/Latest.d" "${DestPath}/${McEdition}"
GitPullPushPath "${DestPath}"
GitPullPushPath "${DestPath}" || true
fi
}
ServerBackupLimited
ArticlesBackupPrivate
DoSpaccBbsBackup
DoSpaccCraftBackup
ServerBackupLimited || true
ArticlesBackupPrivate || true
DoSpaccBbsBackup || true
DoSpaccCraftBackup || true
#GitPullPushPath "/Cloud/Repos/Personal-Game-Saves"
#GitPullPushPath "/media/Disk/Configs"

View File

@@ -31,6 +31,7 @@ DoBackupSpaccBBS(){
SimpleBackup SpaccBBS www
lxc-attach Debian2023 -- sh -c "mariadb-dump phpBB > ${PWD}/SpaccBBS/Db.Latest.sql"
SimpleCompress "./SpaccBBS/Db.${RunDate}.sql" ./SpaccBBS/Db.Latest.sql
EchoExec rm ./SpaccBBS/Db.Latest.sql.tar.xz
EchoExec ln -s "./Db.${RunDate}.sql.tar.xz" ./SpaccBBS/Db.Latest.sql.tar.xz
}

View File

@@ -0,0 +1,18 @@
#!/bin/sh
for Dir in \
Public \
; do
cd "/Main/${Dir}"
chown -R root:root .
chmod -R 7777 .
done
#Server \
#Backup \
chown -R 1000:1000 /Main/Server/Desktop
chown -R 101000:101000 /Main/Server/TelegramIndex-Fork
#chmod -R 7777 /Main/Server/Desktop
chown -R 100033:100033 /Main/Server/www
#chmod -R 7777 /Main/Server/www