sparkyfitness: add data backup and restore

This commit is contained in:
Tom Frenzel
2026-02-21 16:17:31 +01:00
parent b533a7b3e5
commit b04eeba2b6
2 changed files with 15 additions and 2 deletions

View File

@@ -37,6 +37,16 @@ function update_script() {
systemctl stop sparkyfitness-server nginx
msg_ok "Stopped Services"
msg_info "Backing up data"
mkdir -p "/opt/sparkyfitness_backup"
if [[ -d "/opt/sparkyfitness/SparkyFitnessServer/uploads" ]]; then
cp -r "/opt/sparkyfitness/SparkyFitnessServer/uploads" "/opt/sparkyfitness_backup/"
fi
if [[ -d "/opt/sparkyfitness/SparkyFitnessServer/backup" ]]; then
cp -r "/opt/sparkyfitness/SparkyFitnessServer/backup" "/opt/sparkyfitness_backup/"
fi
msg_ok "Backed up data"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "sparkyfitness" "CodeWithCJ/SparkyFitness" "tarball"
msg_info "Updating Sparky Fitness Backend"
@@ -51,6 +61,11 @@ function update_script() {
cp -a "/opt/sparkyfitness/SparkyFitnessFrontend/dist/." "/var/www/sparkyfitness/"
msg_ok "Updated Sparky Fitness Frontend"
msg_info "Restoring data"
cp -r "/opt/sparkyfitness_backup/." "/opt/sparkyfitness/SparkyFitnessServer/"
rm -rf "/opt/sparkyfitness_backup"
msg_ok "Restored data"
msg_info "Starting Services"
$STD systemctl start sparkyfitness-server nginx
msg_ok "Started Services"