Add backup loop to start_server_managed.sh
This commit is contained in:
1 parent
847c1a5009
commit
3a8f3d9cd4
1 file changed
+30
@@ -2,11 +2,41 @@ cat > "${VALHEIMDIR}/start_server_managed.sh" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# -------------------------
|
||||
# BACKUP FUNCTION + LOOP
|
||||
# -------------------------
|
||||
|
||||
backup_world() {
|
||||
echo "[backup] backing up world directory..."
|
||||
ts=$(date +"%Y-%m-%d_%H-%M-%S")
|
||||
|
||||
world_dir="/root/.config/unity3d/IronGate/Valheim/worlds_local/${WORLD_NAME}"
|
||||
|
||||
if [ -d "${world_dir}" ]; then
|
||||
mkdir -p "/mnt/backups"
|
||||
zip -r "/mnt/backups/${WORLD_NAME}_${ts}.zip" "${world_dir}"
|
||||
echo "[backup] created /mnt/backups/${WORLD_NAME}_${ts}.zip"
|
||||
else
|
||||
echo "[backup] WARNING: world directory not found: ${world_dir}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Run backups every hour in background
|
||||
while true; do
|
||||
sleep 3600
|
||||
backup_world
|
||||
done &
|
||||
|
||||
# -------------------------
|
||||
# START SERVER
|
||||
# -------------------------
|
||||
|
||||
# Forward environment variables into the BepInEx launcher
|
||||
exec ./start_server_bepinex.sh \
|
||||
-name "${SERVER_NAME}" \
|
||||
-port 2456 \
|
||||
-world "${WORLD_NAME}" \
|
||||
-savedir "/root/.config/unity3d/IronGate/Valheim/worlds_local" \
|
||||
-password "${SERVER_PASSWORD}" \
|
||||
-public "${PUBLIC}"
|
||||
EOF
|
||||
|
||||
Reference in new issue
Block a user