Game Server Backup and Restore
Game server automatic backup, cron configuration, remote backup with rsync, and world file management guide.
Table of Contents
Introduction
Game server backup is the most critical step in preventing data loss. World files, player data, configuration files, and mod/plugin settings should be backed up regularly. This guide covers automatic backup scripts, cron configuration, remote backup with rsync, and world file management for different game servers.
Backup Strategy
3-2-1 Rule
- 3 copies: Original + 2 backups
- 2 different media: Local disk + remote server
- 1 offsite: Backup at a different location
Backup Types
| Type | Description | Advantage | Disadvantage |
|---|---|---|---|
| Full | Backs up all files | Easy restore | Large size |
| Incremental | Only changed files | Small size | Complex restore |
| Differential | Changes since last full | Medium size | Medium complexity |
Automatic Backup Script
General Purpose Backup
nano ~/backup_gameserver.sh
#!/bin/bash
GAME_NAME=${1:-"gameserver"}
BACKUP_BASE="/home/steam/backups"
DATE=$(date +%Y%m%d_%H%M%S)
RETENTION_DAYS=7
LOG="/home/steam/backup.log"
declare -A SAVE_DIRS
SAVE_DIRS[minecraft]="/home/steam/minecraft/world /home/steam/minecraft/plugins"
SAVE_DIRS[rust]="/home/steam/rustserver/server/rust /home/steam/rustserver/oxide"
SAVE_DIRS[fivem]="/home/steam/fxserver/resources /home/steam/fxserver/server-data"
SAVE_DIRS[vrising]="/home/steam/vrising/save-data"
SAVE_DIRS[satisfactory]="/home/steam/satisfactory/.config/Epic/FactoryServer/Saved/SaveGames"
SAVE_DIRS[pz]="/home/steam/Zomboid/Saves /home/steam/Zomboid/Server"
SAVE_DIRS[enshrouded]="/home/steam/enshrouded/savegame"
BACKUP_DIR="$BACKUP_BASE/$GAME_NAME"
mkdir -p "$BACKUP_DIR"
echo "$(date): Starting $GAME_NAME backup..." >> $LOG
if [ -n "${SAVE_DIRS[$GAME_NAME]}" ]; then
tar -czf "$BACKUP_DIR/${GAME_NAME}_${DATE}.tar.gz" ${SAVE_DIRS[$GAME_NAME]} 2>/dev/null
if [ $? -eq 0 ]; then
SIZE=$(du -h "$BACKUP_DIR/${GAME_NAME}_${DATE}.tar.gz" | cut -f1)
echo "$(date): Backup successful - $SIZE" >> $LOG
else
echo "$(date): ERROR - Backup failed!" >> $LOG
fi
else
echo "$(date): ERROR - Unknown game: $GAME_NAME" >> $LOG
exit 1
fi
find "$BACKUP_DIR" -name "*.tar.gz" -mtime +$RETENTION_DAYS -delete
COUNT=$(find "$BACKUP_DIR" -name "*.tar.gz" | wc -l)
echo "$(date): Cleanup done. Current backup count: $COUNT" >> $LOG
chmod +x ~/backup_gameserver.sh
Cron Automatic Backup
Crontab Configuration
crontab -e
# Backup Minecraft every 4 hours
0 */4 * * * /home/steam/backup_gameserver.sh minecraft
# Backup Rust every 6 hours
0 */6 * * * /home/steam/backup_gameserver.sh rust
# Daily FiveM backup
0 3 * * * /home/steam/backup_gameserver.sh fivem
# Daily V Rising backup
0 4 * * * /home/steam/backup_gameserver.sh vrising
# Weekly full backup (Sunday 02:00)
0 2 * * 0 /home/steam/backup_full.sh
Cron Expression Guide
# minute (0-59) | hour (0-23) | day (1-31) | month (1-12) | weekday (0-7)
# * * * * * command
Remote Backup with rsync
rsync Installation
sudo apt install rsync -y
Backup to Remote Server
nano ~/remote_backup.sh
#!/bin/bash
REMOTE_HOST="backup.example.com"
REMOTE_USER="backup"
REMOTE_DIR="/backups/gameserver"
LOCAL_DIR="/home/steam/backups"
LOG="/home/steam/remote_backup.log"
echo "$(date): Starting remote backup..." >> $LOG
rsync -avz --delete \
-e "ssh -p 22 -i /home/steam/.ssh/backup_key" \
"$LOCAL_DIR/" \
"$REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR/"
if [ $? -eq 0 ]; then
echo "$(date): Remote backup successful." >> $LOG
else
echo "$(date): ERROR - Remote backup failed!" >> $LOG
fi
chmod +x ~/remote_backup.sh
crontab -e
0 5 * * * /home/steam/remote_backup.sh
rsync Parameters
| Parameter | Description |
|---|---|
| -a | Archive mode (preserves permissions, dates) |
| -v | Verbose output |
| -z | Compression |
| --delete | Delete files not in source from destination |
| -e | SSH connection parameters |
World File Management
Minecraft World Files
# World directories
~/minecraft/world/
~/minecraft/world_nether/
~/minecraft/world_the_end/
# Save before backup
screen -S minecraft -p 0 -X stuff "save-all\n"
sleep 5
screen -S minecraft -p 0 -X stuff "save-off\n"
tar -czf ~/backups/minecraft/world_$(date +%Y%m%d).tar.gz ~/minecraft/world*
screen -S minecraft -p 0 -X stuff "save-on\n"
Rust World Files
~/rustserver/server/rust/
~/rustserver/server/rust/player.blueprints.5.db
~/rustserver/server/rust/proceduralmap.*.sav
Restoration
General Restoration Steps
# 1. Stop server
sudo systemctl stop gameserver
# 2. Backup current files (safety)
mv ~/gameserver/save ~/gameserver/save_old
# 3. Restore backup
tar -xzf ~/backups/gameserver/gameserver_20250101_120000.tar.gz -C /
# 4. Start server
sudo systemctl start gameserver
# 5. Check logs
sudo journalctl -u gameserver -f
Restoring Specific Files
# List backup contents
tar -tzf ~/backups/gameserver/gameserver_20250101_120000.tar.gz
# Extract specific file
tar -xzf ~/backups/gameserver/gameserver_20250101_120000.tar.gz home/steam/gameserver/config.ini
Backup Monitoring
# Check backup sizes
du -sh ~/backups/*/
# List recent backups
ls -lht ~/backups/minecraft/ | head -10
# Check disk usage
df -h
Conclusion
Regular backup is an essential part of game server management. Using automatic backup scripts, cron scheduling, and rsync remote backup, you can keep your data safe. REXE VDS NVMe SSD infrastructure provides fast backup and restore operations.
Related Articles
How to Set Up a FiveM Server: Step-by-Step Guide
Complete FiveM server setup guide on REXE VDS: installation, txAdmin configuration, port settings, and performance optimization tips for GTA V roleplay servers.
How to Set Up a Minecraft Server: Paper Installation Guide
Complete Minecraft server setup guide on REXE VDS: Paper/Spigot installation, Java configuration, plugin management, and performance optimization for stable gameplay.
How to Set Up a CS2 Dedicated Server: Complete Guide
Complete CS2 dedicated server setup guide on REXE VDS: SteamCMD installation, GSLT token, server configuration, game modes, and DDoS protection with Path Panel.