mirror of
https://gitlab.com/octospacc/Configs.git
synced 2025-02-02 15:06:56 +01:00
New server
This commit is contained in:
parent
57e77ccf8c
commit
a7ed28ff02
13
Lib.sh
13
Lib.sh
@ -36,11 +36,14 @@ CpSufx(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpfile(){
|
cpfile(){
|
||||||
echo "$1"
|
if [ -f "${ScopePath}$1" ]
|
||||||
rm -rf "./$1" && \
|
then
|
||||||
mkdir -p "./$1" && \
|
echo "$1"
|
||||||
rm -rf "./$1" && \
|
rm -rf "./$1" && \
|
||||||
cp --no-target-directory "${ScopePath}$1" "./$1"
|
mkdir -p "./$1" && \
|
||||||
|
rm -rf "./$1" && \
|
||||||
|
cp --no-target-directory "${ScopePath}$1" "./$1"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cpdir(){
|
cpdir(){
|
||||||
|
@ -21,11 +21,13 @@ mkcd ./Root
|
|||||||
CpItem etc/nginx/nginx.conf
|
CpItem etc/nginx/nginx.conf
|
||||||
CpSufx "etc/nginx/sites-available/*." conf old
|
CpSufx "etc/nginx/sites-available/*." conf old
|
||||||
CpItem etc/tor/torrc
|
CpItem etc/tor/torrc
|
||||||
CpSufx "Server/Scripts/Backup/*." sh cfg
|
CpSufx "Main/Server/Scripts/Backup/*." sh cfg
|
||||||
CpItem Server/Scripts/OneShot.AfterBoot.sh
|
CpSufx "Main/Server/Scripts/Interactive/*." sh
|
||||||
|
CpItem Main/Server/Scripts/OneShot.AfterBoot.sh
|
||||||
|
CpItem Main/Server/Scripts/RenewCerts.sh
|
||||||
|
|
||||||
CpItem Server/Start/bittorrentd
|
CpItem Main/Server/Start/bittorrentd
|
||||||
CpItem Transfers/aria2/Conf
|
CpItem Main/Transfers/aria2/Conf
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
3
Server/Root/Server/Scripts/Backup/BackupGlobals.cfg → Server/Root/Main/Server/Scripts/Backup/BackupGlobals.cfg
Normal file → Executable file
3
Server/Root/Server/Scripts/Backup/BackupGlobals.cfg → Server/Root/Main/Server/Scripts/Backup/BackupGlobals.cfg
Normal file → Executable file
@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
BackupsBase="/media/Disk/Backup"
|
BackupsBase=/Main/Backup
|
||||||
|
#BackupsBase="/media/Disk/Backup"
|
||||||
|
|
||||||
# ScriptDir="$( dirname "$( realpath "$0" )" )"
|
# ScriptDir="$( dirname "$( realpath "$0" )" )"
|
||||||
# cd "$ScriptDir"
|
# cd "$ScriptDir"
|
@ -24,27 +24,28 @@ BackPathCrypt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerBackupLimited(){
|
ServerBackupLimited(){
|
||||||
cd ./Server-Backup-Limited
|
EchoExec cd ./Server-Backup-Limited
|
||||||
#BackPathCrypt "Invidious-User" "${BackupKey_Git_Invidious}" ".7z"
|
#BackPathCrypt "Invidious-User" "${BackupKey_Git_Invidious}" ".7z"
|
||||||
#BackPathCrypt "wallabag-data" "${BackupKey_Git_wallabag}"
|
#BackPathCrypt "wallabag-data" "${BackupKey_Git_wallabag}"
|
||||||
BackPathCrypt FreshRSS "${BackupKey_Git_FreshRSS}"
|
BackPathCrypt FreshRSS "${BackupKey_Git_FreshRSS}"
|
||||||
#BackPathCrypt "FreshRSS-data" "${BackupKey_Git_FreshRSS}"
|
#BackPathCrypt "FreshRSS-data" "${BackupKey_Git_FreshRSS}"
|
||||||
#BackPathCrypt "shiori-data" "${BackupKey_Git_Shiori}"
|
#BackPathCrypt "shiori-data" "${BackupKey_Git_Shiori}"
|
||||||
|
BackPathCrypt n8n-data "${BackupKey_Git_n8n}"
|
||||||
# "${BackupKey_Git_aria2}" ".7z"
|
# "${BackupKey_Git_aria2}" ".7z"
|
||||||
GitPush
|
GitPush
|
||||||
cd ..
|
EchoExec cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
ArticlesBackupPrivate(){
|
ArticlesBackupPrivate(){
|
||||||
cd ./Articles-Backup-Private
|
EchoExec cd ./Articles-Backup-Private
|
||||||
EchoExec rm -rf ./shiori-data
|
EchoExec rm -rf ./shiori-data
|
||||||
EchoExec cp -rp "../shiori-data/Latest.d" "./shiori-data"
|
EchoExec cp -rp "../shiori-data/Latest.d" "./shiori-data"
|
||||||
GitPush
|
GitPush
|
||||||
cd ..
|
EchoExec cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaccBbsBackup(){
|
DoSpaccBbsBackup(){
|
||||||
cd ./SpaccBBS-Backup-phpBB-2023
|
EchoExec cd ./SpaccBBS-Backup-phpBB-2023
|
||||||
EchoExec rm -rf ./SpaccBBS || true
|
EchoExec rm -rf ./SpaccBBS || true
|
||||||
EchoExec cp -rp ../SpaccBBS/Latest.d ./SpaccBBS
|
EchoExec cp -rp ../SpaccBBS/Latest.d ./SpaccBBS
|
||||||
EchoExec cp ../SpaccBBS/Db.Latest.sql.tar.xz ./Db.sql.tar.xz
|
EchoExec cp ../SpaccBBS/Db.Latest.sql.tar.xz ./Db.sql.tar.xz
|
||||||
@ -55,14 +56,15 @@ SpaccBbsBackup(){
|
|||||||
; do ccencryptNow "$File" "$BackupKey_Git_SpaccBBS"
|
; do ccencryptNow "$File" "$BackupKey_Git_SpaccBBS"
|
||||||
done
|
done
|
||||||
GitPush
|
GitPush
|
||||||
cd ..
|
EchoExec cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaccBbsBackup(){
|
DoSpaccCraftBackup(){
|
||||||
McServer="SpaccCraft"
|
McServer="SpaccCraft"
|
||||||
McEdition="Beta-1.7.3"
|
McEdition="Beta-1.7.3"
|
||||||
McGit="spacccraft-b1.7.3-backup4"
|
McGit="spacccraft-b1.7.3-backup4"
|
||||||
DestPath="${BackupsBase}/${McServer}/${McGit}"
|
DestPath="${BackupsBase}/${McGit}"
|
||||||
|
#DestPath="${BackupsBase}/${McServer}/${McGit}"
|
||||||
if [ -d "${DestPath}" ]
|
if [ -d "${DestPath}" ]
|
||||||
then
|
then
|
||||||
#cd "/Server/${McServer}"
|
#cd "/Server/${McServer}"
|
||||||
@ -76,9 +78,9 @@ SpaccBbsBackup(){
|
|||||||
|
|
||||||
ServerBackupLimited
|
ServerBackupLimited
|
||||||
ArticlesBackupPrivate
|
ArticlesBackupPrivate
|
||||||
SpaccBbsBackup
|
DoSpaccBbsBackup
|
||||||
SpaccCraftBackup
|
DoSpaccCraftBackup
|
||||||
GitPullPushPath "/Cloud/Repos/Personal-Game-Saves"
|
#GitPullPushPath "/Cloud/Repos/Personal-Game-Saves"
|
||||||
#GitPullPushPath "/media/Disk/Configs"
|
#GitPullPushPath "/media/Disk/Configs"
|
||||||
|
|
||||||
#CloudDir="/home/octo/Cloud"
|
#CloudDir="/home/octo/Cloud"
|
@ -16,23 +16,30 @@ SimpleBackup(){
|
|||||||
#cp "./$1/${RunDate}.tar.xz" "./$1/Latest.tar.xz"
|
#cp "./$1/${RunDate}.tar.xz" "./$1/Latest.tar.xz"
|
||||||
EchoExec rm "./$1/Latest.tar.xz" || true
|
EchoExec rm "./$1/Latest.tar.xz" || true
|
||||||
EchoExec rm -rf "./$1/Latest.d" || true
|
EchoExec rm -rf "./$1/Latest.d" || true
|
||||||
EchoExec cp -rp "/Server/$2/$1" "./$1/Latest.d"
|
EchoExec cp -rp "/Main/Server/$2/$1" "./$1/Latest.d"
|
||||||
SimpleCompress "./$1/${RunDate}" "./$1/Latest.d"
|
SimpleCompress "./$1/${RunDate}" "./$1/Latest.d"
|
||||||
#cp -v "./$1/${RunDate}.tar.xz" "./$1/Latest.tar.xz"
|
#cp -v "./$1/${RunDate}.tar.xz" "./$1/Latest.tar.xz"
|
||||||
EchoExec ln -s "./${RunDate}.tar.xz" "./$1/Latest.tar.xz"
|
EchoExec ln -s "./${RunDate}.tar.xz" "./$1/Latest.tar.xz"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoBackupShiori(){
|
||||||
|
SimpleBackup shiori-data Shiori
|
||||||
|
rm -v ./shiori-data/Latest.d/archive/* || true
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ln -s "./Db.${RunDate}.sql.tar.xz" ./SpaccBBS/Db.Latest.sql.tar.xz
|
||||||
|
}
|
||||||
|
|
||||||
#SimpleBackup "wallabag-data"
|
#SimpleBackup "wallabag-data"
|
||||||
#SimpleBackup "FreshRSS-data"
|
#SimpleBackup "FreshRSS-data"
|
||||||
SimpleBackup FreshRSS www
|
SimpleBackup FreshRSS www
|
||||||
|
SimpleBackup n8n-data
|
||||||
SimpleBackup shiori-data Shiori
|
DoBackupShiori
|
||||||
rm -v ./shiori-data/Latest.d/archive/* || true
|
DoBackupSpaccBBS
|
||||||
|
|
||||||
SimpleBackup SpaccBBS www
|
|
||||||
EchoExec mariadb-dump phpBB > ./SpaccBBS/Db.Latest.sql
|
|
||||||
SimpleCompress "./SpaccBBS/Db.${RunDate}.sql" ./SpaccBBS/Db.Latest.sql
|
|
||||||
EchoExec ln -s "./Db.${RunDate}.sql.tar.xz" ./SpaccBBS/Db.Latest.sql.tar.xz
|
|
||||||
|
|
||||||
# GoToSocial
|
# GoToSocial
|
||||||
#Name="GoToSocial"
|
#Name="GoToSocial"
|
@ -2,13 +2,15 @@
|
|||||||
# diycron: Script to be running (as a root daemon) as a (non-conflicting) cron alternative which simply works.
|
# diycron: Script to be running (as a root daemon) as a (non-conflicting) cron alternative which simply works.
|
||||||
# Note: Except when required by the shell, we use 0=false, 1=true for internal commands, for consistency.
|
# Note: Except when required by the shell, we use 0=false, 1=true for internal commands, for consistency.
|
||||||
|
|
||||||
If() { test "$1" = 1 && return 0 || return 1; }
|
If(){ test "$1" = 1 && return 0 || return 1 ;}
|
||||||
Ifn() { test "$1" = 0 && return 0 || return 1; }
|
Ifn(){ test "$1" = 0 && return 0 || return 1 ;}
|
||||||
|
|
||||||
GetDaySeconds() { echo "$(date -d "1970-01-01 UTC $(date +%T)" +%s)"; }
|
GetDaySeconds(){ echo "$(date -d "1970-01-01 UTC $(date +%T)" +%s)" ;}
|
||||||
IsDayMin() { test $(($(GetDaySeconds)>$1)) = 1 && test $(($(GetDaySeconds)<$1+60)) = 1 && echo 1 || echo 0; }
|
IsDayMin(){ [ "$(GetDaySeconds)" -gt "$1" ] && [ "$(GetDaySeconds)" -lt "$(($1 + 60))" ] && echo 1 || echo 0 ;}
|
||||||
IsHourMin() { test "$1" = "$(date +%M)" && echo 1 || echo 0; }
|
IsHourMin(){ [ "$1" = "$(date +%M)" ] && echo 1 || echo 0 ;}
|
||||||
hm2s() { echo $((($1*60*60) + ($2*60))); }
|
hm2s(){ echo $((($1*60*60) + ($2*60))) ;}
|
||||||
|
|
||||||
|
Do(){ echo "Running: $@" && $@ ;}
|
||||||
|
|
||||||
# Setting variables (that always have a "Job" prefix) for each job, to prevent multiple execution.
|
# Setting variables (that always have a "Job" prefix) for each job, to prevent multiple execution.
|
||||||
ResetJobs() {
|
ResetJobs() {
|
||||||
@ -21,7 +23,7 @@ ResetJobs() {
|
|||||||
echo "------------------------------------------"
|
echo "------------------------------------------"
|
||||||
echo "[ $(date "+%F | %T") ] diycron started."
|
echo "[ $(date "+%F | %T") ] diycron started."
|
||||||
|
|
||||||
set -x # Enable command echo
|
#set -x # Enable command echo
|
||||||
ResetJobs
|
ResetJobs
|
||||||
|
|
||||||
while true
|
while true
|
||||||
@ -29,19 +31,19 @@ do
|
|||||||
# Inside here, declaration of all cronjobs like normal shell commands, made easy thanks to integrated functions.
|
# Inside here, declaration of all cronjobs like normal shell commands, made easy thanks to integrated functions.
|
||||||
|
|
||||||
# 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
|
# 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 && sleep 60 && /Server/Scripts/Backup/ExternalDataBackup.sh #& # Local backup of external data
|
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 0 && Job2=1 && sleep 60 && Do sh /Main/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)) = 1 && Job2=1 && sleep 60 && Do sh /Main/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
|
Ifn $Job2 && If $(IsDayMin $(hm2s 3 0)) && test $(($(date +%s) / 86400 % 3)) = 2 && Job2=1 && sleep 60 && Do sh /Main/Server/Scripts/Backup/CloudBackup.sh #& # Cloud backup of the locally backed-up data
|
||||||
|
|
||||||
# System reboot every X days at 4:30 AM
|
# System reboot every X days at 4:30 AM
|
||||||
#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)) && 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
|
||||||
|
|
||||||
# Try to renew SSL certs every 5 days at 4 AM
|
# Try to renew SSL certs every 5 days at 4 AM
|
||||||
Ifn $JobCerts && If $(IsDayMin $(hm2s 4 0)) && test $(($(date +%s) / 86400 % 9)) = 0 && JobCerts=1 && sleep 60 && /Server/Scripts/RenewCerts.sh
|
Ifn $JobCerts && If $(IsDayMin $(hm2s 4 0)) && test $(($(date +%s) / 86400 % 9)) = 0 && JobCerts=1 && sleep 60 && Do lxc-attach Debian2023 sh /Main/Server/Scripts/RenewCerts.sh
|
||||||
|
|
||||||
# Status of all jobs is reset at one time of the day, before or after all execute or have executed (in time).
|
# 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
|
If $(IsDayMin $(hm2s 0 0)) && Do ResetJobs
|
||||||
# Cooldown to wait at each cycle, to save on resources (Should always be less than 60 seconds!).
|
# Cooldown to wait at each cycle, to save on resources (Should always be less than 60 seconds!).
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=diycron
|
Description=diycron
|
||||||
After=network.target
|
After=network.target
|
||||||
StartLimitIntervalSec=0
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
|
Loading…
x
Reference in New Issue
Block a user