Backup Scripts

This commit is contained in:
octospacc 2023-01-31 09:48:04 +01:00
parent e72ce34734
commit 9b6e4b4c4c
6 changed files with 30 additions and 12 deletions

7
Server/.Repo.Update.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
cd "$( dirname "$( realpath "$0" )" )"
cp -v /etc/diycron ./diycron
cp -v /Server/Scripts/Backup/*.sh ./Scripts/Backup/
cp -v /Server/Scripts/Backup/*.cfg ./Scripts/Backup/

View File

@ -21,3 +21,7 @@ ccencryptNow() {
BaseKey="$2"
ccrypt -e -f -K"$(Hash2 "${BaseKey}" "${RunDate}")" "${File}"
}
WriteLastLog() {
echo "$0: $(date)" > "${BackupsBase}/Last.log"
}

View File

@ -4,9 +4,14 @@
. "$(dirname "$(realpath "$0")")/BackupGlobals.cfg"
GitPush() {
git add .
git commit -m "Auto-Backup $(date) (${RunDate})"
git push
Msg="Auto-Backup $(date) (${RunDate})"
git add . && git commit -m "${Msg}" && git push
}
GitPullPushPath() {
BackPath="$(pwd)"
cd "$1" && git pull && GitPush
cd "${BackPath}"
}
cd ./Server-Backup-Limited
@ -16,6 +21,8 @@ Item="FreshRSS-data" && cp "../${Item}/Latest.tar.xz" "./${Item}.tar.xz" && ccen
GitPush
cd ..
#GitPullPushPath "./Personal-Game-Saves"
#CloudDir="/home/octo/Cloud"
#cd "$CloudDir"
@ -51,4 +58,4 @@ cd ..
#done
#GitPush
date > "${BackupsBase}/Last.log"
WriteLastLog

View File

@ -11,4 +11,4 @@ curl \
-H "${Invidious_Backup_Cookie}" \
| 7z a -mmt1 -mx9 "./${Name}/${RunDate}.7z" -si && cp "./${Name}/${RunDate}.7z" "./${Name}/Latest.7z"
date > "${BackupsBase}/Last.log"
WriteLastLog

View File

@ -41,4 +41,4 @@ SimpleBackup "FreshRSS-data"
# cd ..
#done
date > "${BackupsBase}/Last.log"
WriteLastLog

View File

@ -31,16 +31,16 @@ do
# If $(IsHourMin 25) && sudo -u pi /Server/Scripts/sitoctt-Downsync.sh
# Trinity rotation backup system: each of the following scripts is executed every 3 days, in a rotation where at least 1 script runs every night at 3:00
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 0 && Job2=1 && /Server/Scripts/Backup/ExternalDataBackup.sh & # Local backup of external data
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 1 && Job2=1 && /Server/Scripts/Backup/ServerDataBackup.sh & # Big backup of local services data
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 2 && Job2=1 && /Server/Scripts/Backup/CloudBackup.sh & # Cloud backup of the locally backed-up data
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 0 && Job2=1 && sleep 60 && /Server/Scripts/Backup/ExternalDataBackup.sh #& # Local backup of external data
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 1 && Job2=1 && sleep 60 && /Server/Scripts/Backup/ServerDataBackup.sh #& # Big backup of local services data
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 2 && Job2=1 && sleep 60 && /Server/Scripts/Backup/CloudBackup.sh #& # Cloud backup of the locally backed-up data
# Clean Misskey cache daily
# If $(IsDayMin $(hm2s 2 30)) && curl 'https://miss.octt.eu.org/api/admin/drive/clean-remote-files' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Firefox/107.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Referer: https://miss.octt.eu.org/' -H 'Origin: https://miss.octt.eu.org' -H 'DNT: 1' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' -H 'Connection: keep-alive' --data-raw '{"i":"TOKEN"}'
# System reboot every X days
If $(IsDayMin $(hm2s 4 30)) && test $(($(date +%s) / 86400 % 2)) = 0 && sleep 60 && reboot
# System reboot every X days at 4:30 AM
#If $(IsDayMin $(hm2s 4 30)) && test $(($(date +%s) / 86400 % 2)) = 0 && sleep 60 && reboot
#If $(IsDayMin $(hm2s 4 30)) && test $(($(date +%s) / 86400 % 2)) = 0 && sleep 60 && reboot # System reboot every 2 days (every even day)
#If $(IsDayMin $(hm2s 4 30)) && sleep 60 && reboot # System reboot every night
If $(IsDayMin $(hm2s 4 30)) && sleep 60 && reboot # System reboot every night
# Status of all jobs is reset at one time of the day, before or after all execute or have executed (in time).
If $(IsDayMin $(hm2s 0 0)) && ResetJobs