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
No known key found for this signature in database
GPG Key ID: 02BEE95E635A32FC
2 changed files with 15 additions and 2 deletions

View File

@ -37,6 +37,16 @@ function update_script() {
systemctl stop sparkyfitness-server nginx systemctl stop sparkyfitness-server nginx
msg_ok "Stopped Services" 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" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "sparkyfitness" "CodeWithCJ/SparkyFitness" "tarball"
msg_info "Updating Sparky Fitness Backend" msg_info "Updating Sparky Fitness Backend"
@ -51,6 +61,11 @@ function update_script() {
cp -a "/opt/sparkyfitness/SparkyFitnessFrontend/dist/." "/var/www/sparkyfitness/" cp -a "/opt/sparkyfitness/SparkyFitnessFrontend/dist/." "/var/www/sparkyfitness/"
msg_ok "Updated Sparky Fitness Frontend" 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" msg_info "Starting Services"
$STD systemctl start sparkyfitness-server nginx $STD systemctl start sparkyfitness-server nginx
msg_ok "Started Services" msg_ok "Started Services"

View File

@ -39,8 +39,6 @@ sed \
-e "s|^SPARKY_FITNESS_FRONTEND_URL=.*|SPARKY_FITNESS_FRONTEND_URL=http://${LOCAL_IP}:80|" \ -e "s|^SPARKY_FITNESS_FRONTEND_URL=.*|SPARKY_FITNESS_FRONTEND_URL=http://${LOCAL_IP}:80|" \
-e "s|^SPARKY_FITNESS_API_ENCRYPTION_KEY=.*|SPARKY_FITNESS_API_ENCRYPTION_KEY=$(openssl rand -hex 32)|" \ -e "s|^SPARKY_FITNESS_API_ENCRYPTION_KEY=.*|SPARKY_FITNESS_API_ENCRYPTION_KEY=$(openssl rand -hex 32)|" \
-e "s|^BETTER_AUTH_SECRET=.*|BETTER_AUTH_SECRET=$(openssl rand -hex 32)|" \ -e "s|^BETTER_AUTH_SECRET=.*|BETTER_AUTH_SECRET=$(openssl rand -hex 32)|" \
-e "s|^# SERVER_BACKUP_PATH=.*|SERVER_BACKUP_PATH=/var/lib/sparkyfitness/backup|" \
-e "s|^# SERVER_UPLOADS_PATH=.*|SERVER_UPLOADS_PATH=/var/lib/sparkyfitness/uploads|" \
"/etc/sparkyfitness/.env" "/etc/sparkyfitness/.env"
msg_ok "Configured Sparky Fitness" msg_ok "Configured Sparky Fitness"