Sons of the Forest: Complete Backup Management Guide
Essential guide to backing up and restoring Sons of the Forest server data, including world saves, player progress, configurations, and disaster recovery procedures.
Understanding Server Data Structure
Critical Data Components
- World Saves: Main world data and terrain generation
- Player Data: Character progress, inventory, and stats
- Server Configuration: Game settings and server parameters
- Log Files: Server activity and error logs
- Mod Data: Installed modifications and their configurations
File Locations
# Windows Default Installation
C:\Program Files (x86)\Steam\steamapps\common\Sons of The Forest\DS\
├── Saves/ # World save files
│ ├── multiplayer/
│ │ └── ServerName/
│ │ ├── SaveFile.sav # Main world save
│ │ ├── PlayerData/ # Player character data
│ │ └── config.json # Server configuration
├── Logs/ # Server logs
├── Mods/ # Installed modifications
└── DedicatedServer/ # Server executable files
# Linux SteamCMD Installation
/home/sonsoftheforest/server/
├── Saves/
├── Logs/
├── Mods/
└── DedicatedServer/
Manual Backup Procedures
Immediate Backup Script
#!/bin/bash
# sotf_backup.sh
SERVER_DIR="/home/sonsoftheforest/server"
BACKUP_DIR="/home/backups/sonsoftheforest"
DATE=$(date +%Y%m%d_%H%M%S)
MAX_BACKUPS=7
mkdir -p "$BACKUP_DIR"
echo "Starting Sons of the Forest backup..."
# Stop the dedicated server
echo "Stopping dedicated server..."
pkill -f "SonsOfTheForestDS.exe"
# Wait for server to fully stop
sleep 10
# Create backup directory
mkdir -p "$BACKUP_DIR/backup_$DATE"
# Backup critical data
echo "Copying world saves..."
cp -r "$SERVER_DIR/Saves" "$BACKUP_DIR/backup_$DATE/"
echo "Copying server configuration..."
cp -r "$SERVER_DIR/DedicatedServer/config" "$BACKUP_DIR/backup_$DATE/"
echo "Copying mod files..."
if [ -d "$SERVER_DIR/Mods" ]; then
cp -r "$SERVER_DIR/Mods" "$BACKUP_DIR/backup_$DATE/"
fi
echo "Copying log files..."
cp -r "$SERVER_DIR/Logs" "$BACKUP_DIR/backup_$DATE/"
# Create compressed archive
echo "Creating compressed archive..."
cd "$BACKUP_DIR"
tar -czf "sotf_backup_$DATE.tar.gz" "backup_$DATE/"
rm -rf "backup_$DATE/"
# Get backup size
BACKUP_SIZE=$(du -h "sotf_backup_$DATE.tar.gz" | cut -f1)
# Restart the server
echo "Starting dedicated server..."
cd "$SERVER_DIR"
nohup ./SonsOfTheForestDS.exe -batchmode -nographics -serversettings config/ServerSettings.ini > /dev/null 2>&1 &
# Clean old backups
echo "Cleaning old backups..."
ls -t sotf_backup_*.tar.gz | tail -n +$((MAX_BACKUPS + 1)) | xargs -r rm
echo "Backup completed: sotf_backup_$DATE.tar.gz (Size: $BACKUP_SIZE)"
echo "Server restarted successfully"
Windows Backup Script
@echo off
REM sotf_backup.bat
SET SERVER_DIR="C:\Program Files (x86)\Steam\steamapps\common\Sons of The Forest\DS"
SET BACKUP_DIR="D:\Backups\SonsOfTheForest"
SET DATE=%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
SET DATE=%DATE: =0%
mkdir "%BACKUP_DIR%"
echo Starting Sons of the Forest backup...
REM Stop dedicated server
echo Stopping dedicated server...
taskkill /f /im "SonsOfTheForestDS.exe" >nul 2>&1
REM Wait for server to stop
timeout /t 10 /nobreak >nul
REM Create backup directory
mkdir "%BACKUP_DIR%\backup_%DATE%"
REM Backup critical data
echo Copying world saves...
xcopy "%SERVER_DIR%\Saves" "%BACKUP_DIR%\backup_%DATE%\Saves\" /E /I /Y /Q
echo Copying server configuration...
xcopy "%SERVER_DIR%\DedicatedServer\config" "%BACKUP_DIR%\backup_%DATE%\config\" /E /I /Y /Q
echo Copying mod files...
if exist "%SERVER_DIR%\Mods" (
xcopy "%SERVER_DIR%\Mods" "%BACKUP_DIR%\backup_%DATE%\Mods\" /E /I /Y /Q
)
echo Copying log files...
xcopy "%SERVER_DIR%\Logs" "%BACKUP_DIR%\backup_%DATE%\Logs\" /E /I /Y /Q
REM Create compressed archive
echo Creating compressed archive...
cd "%BACKUP_DIR%"
tar -a -cf "sotf_backup_%DATE%.zip" "backup_%DATE%\"
rmdir /s /q "backup_%DATE%"
REM Restart server
echo Starting dedicated server...
cd "%SERVER_DIR%"
start "" /B "SonsOfTheForestDS.exe" -batchmode -nographics -serversettings config/ServerSettings.ini
echo Backup completed: sotf_backup_%DATE%.zip
Automated Backup Solutions
Cron Job Configuration
# Edit crontab
crontab -e
# Add backup schedules for Sons of the Forest
# Hourly incremental backup (every hour)
0 * * * * /home/scripts/sotf_incremental.sh >> /home/logs/sotf_backup.log 2>&1
# Daily full backup at 4:00 AM
0 4 * * * /home/scripts/sotf_backup.sh >> /home/logs/sotf_backup.log 2>&1
# Weekly full backup on Sundays at 2:00 AM
0 2 * * 0 /home/scripts/sotf_full_backup.sh >> /home/logs/sotf_backup.log 2>&1
# Monthly cleanup on the 1st at 3:00 AM
0 3 1 * * /home/scripts/sotf_cleanup.sh >> /home/logs/sotf_backup.log 2>&1
Windows Task Scheduler
REM Create scheduled tasks for Sons of the Forest backup
REM Daily backup at 4:00 AM
schtasks /create /tn "SOTF Daily Backup" /tr "C:\Scripts\sotf_backup.bat" /sc daily /st 04:00 /f
REM Weekly backup on Sundays at 2:00 AM
schtasks /create /tn "SOTF Weekly Backup" /tr "C:\Scripts\sotf_full_backup.bat" /sc weekly /d SUN /st 02:00 /f
REM Monthly cleanup on the 1st
schtasks /create /tn "SOTF Monthly Cleanup" /tr "C:\Scripts\sotf_cleanup.bat" /sc monthly /d 1 /st 03:00 /f
REM Hourly incremental backup
schtasks /create /tn "SOTF Hourly Backup" /tr "C:\Scripts\sotf_incremental.bat" /sc hourly /f
Incremental Backup Strategy
Save File Analysis
#!/bin/bash
# sotf_incremental.sh
SERVER_DIR="/home/sonsoftheforest/server"
BACKUP_DIR="/home/backups/sonsoftheforest/incremental"
DATE=$(date +%Y%m%d_%H%M%S)
LAST_BACKUP_FILE="/home/backups/sonsoftheforest/last_backup_time"
mkdir -p "$BACKUP_DIR"
# Get last backup time
if [ -f "$LAST_BACKUP_FILE" ]; then
LAST_BACKUP=$(cat "$LAST_BACKUP_FILE")
else
LAST_BACKUP="1970-01-01 00:00:00"
fi
# Find files modified since last backup
echo "Finding files modified since $LAST_BACKUP"
# Backup changed save files
find "$SERVER_DIR/Saves" -newermt "$LAST_BACKUP" -type f -exec cp --parents {} "$BACKUP_DIR/" \;
# Backup configuration changes
find "$SERVER_DIR/DedicatedServer/config" -newermt "$LAST_BACKUP" -type f -exec cp --parents {} "$BACKUP_DIR/" \;
# Backup new mods
find "$SERVER_DIR/Mods" -newermt "$LAST_BACKUP" -type f -exec cp --parents {} "$BACKUP_DIR/" \;
# Create incremental archive
cd "$BACKUP_DIR"
if [ $(ls -A | wc -l) -gt 0 ]; then
tar -czf "sotf_incremental_$DATE.tar.gz" .
# Clean up copied files
find . -type f -not -name "sotf_incremental_$DATE.tar.gz" -delete
echo "Incremental backup created: sotf_incremental_$DATE.tar.gz"
else
echo "No changes detected - no incremental backup needed"
fi
# Update last backup time
date "+%Y-%m-%d %H:%M:%S" > "$LAST_BACKUP_FILE"
Remote and Cloud Backup
Cloud Storage Integration
#!/bin/bash
# sotf_cloud_backup.sh
LOCAL_BACKUP_DIR="/home/backups/sonsoftheforest"
CLOUD_PROVIDERS=("aws_s3" "gdrive" "dropbox" "onedrive")
# AWS S3 Upload
sotf_upload_s3() {
echo "Uploading to AWS S3..."
aws s3 sync "$LOCAL_BACKUP_DIR" s3://sotf-server-backups/ \
--delete --exclude "*.tmp" --include "*.tar.gz" --include "*.zip"
if [ $? -eq 0 ]; then
echo "S3 upload successful"
else
echo "S3 upload failed - check credentials"
fi
}
# Google Drive Upload
sotf_upload_gdrive() {
echo "Uploading to Google Drive..."
rclone sync "$LOCAL_BACKUP_DIR" gdrive:SOTF-Backups/ \
--delete --exclude "*.tmp" --include "*.{tar.gz,zip}"
if [ $? -eq 0 ]; then
echo "Google Drive upload successful"
else
echo "Google Drive upload failed"
fi
}
# Dropbox Upload
sotf_upload_dropbox() {
echo "Uploading to Dropbox..."
python3 /home/scripts/dropbox_uploader.py \
-f /home/scripts/dropbox.cfg \
-s "$LOCAL_BACKUP_DIR" \
-d "/SOTF-Backups/"
if [ $? -eq 0 ]; then
echo "Dropbox upload successful"
else
echo "Dropbox upload failed"
fi
}
# Upload to all configured providers
for provider in "${CLOUD_PROVIDERS[@]}"; do
case $provider in
"aws_s3")
sotf_upload_s3
;;
"gdrive")
sotf_upload_gdrive
;;
"dropbox")
sotf_upload_dropbox
;;
esac
done
echo "Cloud backup process completed"
Off-site Server Sync
#!/bin/bash
# sotf_remote_sync.sh
LOCAL_BACKUP_DIR="/home/backups/sonsoftheforest"
REMOTE_SERVER="backup.example.com"
REMOTE_DIR="/backups/sonsoftheforest"
SSH_KEY="/home/.ssh/backup_key"
SSH_USER="backupuser"
echo "Starting remote server sync..."
# Test SSH connection
ssh -i "$SSH_KEY" -o ConnectTimeout=10 "$SSH_USER@$REMOTE_SERVER" "echo 'Connection test successful'"
if [ $? -ne 0 ]; then
echo "Failed to connect to remote server - aborting sync"
exit 1
fi
# Perform incremental sync using rsync
echo "Syncing backups to remote server..."
rsync -avz --delete --progress \
-e "ssh -i $SSH_KEY" \
--exclude="*.tmp" \
--include="*.tar.gz" \
--include="*.zip" \
--exclude="*" \
"$LOCAL_BACKUP_DIR/" \
"$SSH_USER@$REMOTE_SERVER:$REMOTE_DIR/"
if [ $? -eq 0 ]; then
echo "Remote sync completed successfully"
# Verify remote backup integrity
ssh -i "$SSH_KEY" "$SSH_USER@$REMOTE_SERVER" \
"cd $REMOTE_DIR && for file in *.tar.gz *.zip; do if [ -f \"\$file\" ]; then tar -tzf \"\$file\" >/dev/null 2>&1 || echo \"CORRUPTED: \$file\"; fi; done"
else
echo "Remote sync failed - check network connectivity and permissions"
# Send alert notification
echo "SOTF backup sync failed at $(date)" | \
mail -s "Backup Sync Alert" admin@example.com
fi
# Clean old remote backups (keep last 14 days)
ssh -i "$SSH_KEY" "$SSH_USER@$REMOTE_SERVER" \
"cd $REMOTE_DIR && ls -t *.tar.gz *.zip | tail -n +15 | xargs -r rm"
echo "Remote backup cleanup completed"
Recovery Procedures
Full Server Recovery
#!/bin/bash
# sotf_restore.sh
BACKUP_FILE="$1"
SERVER_DIR="/home/sonsoftheforest/server"
RESTORE_TEMP="/tmp/sotf_restore_$(date +%s)"
if [ -z "$BACKUP_FILE" ]; then
echo "Usage: $0 "
echo "Example: $0 /home/backups/sonsoftheforest/sotf_backup_20240106_040000.tar.gz"
exit 1
fi
if [ ! -f "$BACKUP_FILE" ]; then
echo "Error: Backup file '$BACKUP_FILE' not found"
exit 1
fi
echo "Starting Sons of the Forest recovery from: $BACKUP_FILE"
# Create temporary restore directory
mkdir -p "$RESTORE_TEMP"
# Extract backup
echo "Extracting backup..."
tar -xzf "$BACKUP_FILE" -C "$RESTORE_TEMP"
# Verify backup integrity
if [ ! -d "$RESTORE_TEMP/backup_*/Saves" ]; then
echo "Error: Invalid backup file - missing Saves directory"
rm -rf "$RESTORE_TEMP"
exit 1
fi
# Stop the dedicated server
echo "Stopping dedicated server..."
pkill -f "SonsOfTheForestDS.exe"
sleep 10
# Create current backup before restoration
echo "Creating emergency backup of current state..."
/home/scripts/sotf_emergency_backup.sh
# Restore world saves
echo "Restoring world saves..."
if [ -d "$SERVER_DIR/Saves" ]; then
mv "$SERVER_DIR/Saves" "$SERVER_DIR/Saves.backup.$(date +%Y%m%d_%H%M%S)"
fi
cp -r "$RESTORE_TEMP/backup_*/Saves" "$SERVER_DIR/"
# Restore configuration
echo "Restoring server configuration..."
if [ -d "$SERVER_DIR/DedicatedServer/config" ]; then
mv "$SERVER_DIR/DedicatedServer/config" "$SERVER_DIR/DedicatedServer/config.backup.$(date +%Y%m%d_%H%M%S)"
fi
cp -r "$RESTORE_TEMP/backup_*/config" "$SERVER_DIR/DedicatedServer/"
# Restore mods if present
if [ -d "$RESTORE_TEMP/backup_*/Mods" ]; then
echo "Restoring mods..."
if [ -d "$SERVER_DIR/Mods" ]; then
mv "$SERVER_DIR/Mods" "$SERVER_DIR/Mods.backup.$(date +%Y%m%d_%H%M%S)"
fi
cp -r "$RESTORE_TEMP/backup_*/Mods" "$SERVER_DIR/"
fi
# Set correct permissions
chown -R sonsoftheforest:sonsoftheforest "$SERVER_DIR"
# Clean up temporary files
rm -rf "$RESTORE_TEMP"
# Restart the server
echo "Starting dedicated server..."
cd "$SERVER_DIR"
nohup ./SonsOfTheForestDS.exe -batchmode -nographics -serversettings config/ServerSettings.ini > /dev/null 2>&1 &
echo "Recovery completed successfully"
echo "Server is starting up..."
Partial Recovery Options
World Save Only
#!/bin/bash
# sotf_restore_world.sh
BACKUP_FILE="$1"
SERVER_DIR="/home/sonsoftheforest/server"
if [ -z "$BACKUP_FILE" ]; then
echo "Usage: $0 "
exit 1
fi
echo "Restoring world save only..."
# Stop server
pkill -f "SonsOfTheForestDS.exe"
sleep 10
# Backup current world
mv "$SERVER_DIR/Saves" "$SERVER_DIR/Saves.backup.$(date +%Y%m%d_%H%M%S)"
# Extract only saves from backup
tar -xzf "$BACKUP_FILE" --wildcards "*/Saves" -C "$SERVER_DIR"
# Restart server
cd "$SERVER_DIR"
nohup ./SonsOfTheForestDS.exe -batchmode -nographics -serversettings config/ServerSettings.ini > /dev/null 2>&1 &
echo "World save restored"
Configuration Only
#!/bin/bash
# sotf_restore_config.sh
BACKUP_FILE="$1"
SERVER_DIR="/home/sonsoftheforest/server"
if [ -z "$BACKUP_FILE" ]; then
echo "Usage: $0 "
exit 1
fi
echo "Restoring server configuration only..."
# Extract only config from backup
tar -xzf "$BACKUP_FILE" --wildcards "*/config" -C "$SERVER_DIR/DedicatedServer/"
echo "Configuration restored - server restart required for changes to take effect"
Monitoring and Maintenance
Backup Health Monitoring
#!/bin/bash
# sotf_backup_monitor.sh
BACKUP_DIR="/home/backups/sonsoftheforest"
ALERT_EMAIL="admin@example.com"
MAX_BACKUP_AGE_HOURS=24
MIN_DISK_SPACE_GB=5
# Check for recent backup
LATEST_BACKUP=$(ls -t "$BACKUP_DIR"/sotf_backup_*.tar.gz 2>/dev/null | head -1)
if [ -z "$LATEST_BACKUP" ]; then
echo "ALERT: No backups found!" | \
mail -s "SOTF Backup Alert" "$ALERT_EMAIL"
exit 1
fi
BACKUP_AGE=$(( ($(date +%s) - $(stat -c %Y "$LATEST_BACKUP")) / 3600 ))
if [ "$BACKUP_AGE" -gt "$MAX_BACKUP_AGE_HOURS" ]; then
echo "ALERT: Latest backup is $BACKUP_AGE hours old" | \
mail -s "SOTF Backup Alert" "$ALERT_EMAIL"
fi
# Check backup integrity
tar -tzf "$LATEST_BACKUP" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ALERT: Latest backup appears corrupted: $LATEST_BACKUP" | \
mail -s "SOTF Backup Alert" "$ALERT_EMAIL"
fi
# Check disk space
AVAILABLE_SPACE=$(df -BG "$BACKUP_DIR" | tail -1 | awk '{print $4}' | sed 's/G//')
if [ "$AVAILABLE_SPACE" -lt "$MIN_DISK_SPACE_GB" ]; then
echo "ALERT: Low disk space ($AVAILABLE_SPACE GB available)" | \
mail -s "SOTF Backup Alert" "$ALERT_EMAIL"
fi
echo "Backup health check completed"
Disaster Recovery Planning
Recovery Time Objectives
Service Level Targets
- RPO (Recovery Point Objective): Maximum 2 hours data loss
- RTO (Recovery Time Objective): Maximum 15 minutes downtime
- Backup Frequency: Every 2 hours for critical, daily for full
- Retention Period: 30 days for daily, 90 days for weekly
Emergency Response Plan
Critical Server Failure Response
- Immediate Assessment: Determine failure scope and impact
- Communication: Notify players via Discord/Steam announcements
- Recovery Initiation: Begin restoration from most recent backup
- Verification: Test server functionality before going live
- Post-Recovery: Monitor for stability and issues
Pro Tip: Always test backup recovery procedures during maintenance windows to ensure they work correctly when actually needed.