RuneScape: Dragonwilds – Guide to Automated Server Backups

How to Host Your Own Server (Rental Service Provider)

You can host a server at game server hosting provider:

Note: Every gaming server goes online immediately! A welcome email including your connection information (guide) will be sent to you when your gaming server is created.

Beginner’s Guide to Automated DragonWilds Server Backups

Once your server is running, protecting your world data is important because power outages or bad game updates can corrupt your save file.

This setup creates an automated backup system that:

  • Checks the server every hour.
  • Creates a backup only when the save file has changed.
  • Keeps backups for 7 days.
  • Warns you if the backup folder exceeds 2.5 GB.

Phase 1: Create the Backup Script

The backup script needs to be owned by the dragonwilds user so it has the required permissions to access the game files.

Switch to the DragonWilds User

If you are currently logged in as your admin user, switch to the game server user:

sudo su - dragonwilds

Create the Backup Script

Create the script inside your server folder:

nano ~/rs_server/auto_backup.sh

Paste the following into the editor:

#!/bin/bash

# Define our variables
SAVE_FILE="/home/dragonwilds/rs_server/RSDragonwilds/Saved/SaveGames/DragonWilds.sav"
BACKUP_DIR="/home/dragonwilds/dragonwilds_backups/worlds"
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
MAX_SIZE_MB=2560 # 2.5GB in Megabytes

# 1. Check if the server is active. If not, exit silently.
if ! systemctl is-active --quiet dragonwilds; then
exit 0
fi

# Ensure the Backup directory exists
mkdir -p "$BACKUP_DIR"

# 2. Check if the file ACTUALLY changed using an MD5 checksum.
# First, find the most recent backup we created
LATEST_BACKUP=$(ls -t "$BACKUP_DIR"/DragonWilds.sav_*.bak 2>/dev/null | head -n 1)

# If a previous backup exists, compare their exact contents
if [ -n "$LATEST_BACKUP" ]; then
CURRENT_HASH=$(md5sum "$SAVE_FILE" | awk '{ print $1 }')
LAST_HASH=$(md5sum "$LATEST_BACKUP" | awk '{ print $1 }')

if [ "$CURRENT_HASH" == "$LAST_HASH" ]; then
echo "Save file contents are identical to the last backup. Skipping."
exit 0
fi
fi

# 3. Copy the file and append the timestamp
# Runs only if hashes differ or no backup exists
cp "$SAVE_FILE" "$BACKUP_DIR/DragonWilds.sav_${TIMESTAMP}.bak"
echo "Backup created successfully at ${TIMESTAMP}."

# 4. Clean up files older than 7 days
find "$BACKUP_DIR" -type f -name "*.bak" -mtime +7 -delete

# 5. Check total folder size and throw a global warning if it exceeds 2.5GB
FOLDER_SIZE=$(du -sm "$BACKUP_DIR" | cut -f1)
if [ "$FOLDER_SIZE" -gt "$MAX_SIZE_MB" ]; then
# 'wall' broadcasts a message to every active terminal window logged into the VM
echo "WARNING: Dragonwilds Backup folder has exceeded 2.5GB! Current size: ${FOLDER_SIZE}MB" | wall
fi

Save and exit with Ctrl+O, press Enter, then press Ctrl+X.

Make the Script Executable

Linux creates text files by default, so you need to explicitly allow the script to run as a program:

chmod +x ~/rs_server/auto_backup.sh

Phase 2: Create the Backup Service

The service tells Ubuntu how to run the backup script.

You need to return to your admin user before creating the system service file:

exit

Create the Service File

Create the service:

sudo nano /etc/systemd/system/dragonwilds-backup.service

Paste the following into the editor:

[Unit]
Description=Runescape Dragonwilds Save Backup

[Service]
Type=oneshot
User=dragonwilds
Group=dragonwilds
ExecStart=/home/dragonwilds/rs_server/auto_backup.sh

Save and exit with Ctrl+O, press Enter, then press Ctrl+X.

Phase 3: Create the Backup Timer

The service defines how the backup runs. The timer defines when it runs.

Create the timer file:

sudo nano /etc/systemd/system/dragonwilds-backup.timer

Paste the following into the editor:

[Unit]
Description=Hourly Timer for Dragonwilds Save Backup

[Timer]
# Run exactly at the top of every hour (e.g., 1:00, 2:00, 3:00)
OnCalendar=hourly
# If the server was offline during a scheduled backup, run it immediately upon booting
Persistent=true

[Install]
WantedBy=timers.target

Save and exit with Ctrl+O, press Enter, then press Ctrl+X.

Phase 4: Enable the Backup Timer

Load the new systemd files and activate the timer:

sudo systemctl daemon-reload
sudo systemctl enable dragonwilds-backup.timer
sudo systemctl start dragonwilds-backup.timer

These commands perform the following actions:

  • daemon-reload refreshes the system.
  • enable makes sure the timer starts automatically if you reboot your VM.
  • start activates the timer immediately.

Verify the Timer

To check whether the timer is active and see when it is scheduled to run next, use:

systemctl list-timers | grep dragonwilds

This shows exactly when the backup script is scheduled to run next.

How the Backup System Works

Every hour, the timer runs the backup service.

The script first checks whether the DragonWilds server is active. If the server is not running, the script exits silently without creating a backup.

If the server is active, the script:

  1. Ensures the backup directory exists.
  2. Finds the most recent backup.
  3. Calculates an MD5 checksum for the current save file and the latest backup.
  4. Skips the backup if the file contents are identical.
  5. Copies the save file into the backup directory with a timestamp if the contents have changed or no previous backup exists.
  6. Deletes .bak files older than 7 days.
  7. Checks the total backup folder size.
  8. Sends a warning to every active terminal window logged into the VM if the folder exceeds 2.5 GB.

Be the first to comment

Leave a Reply

Your email address will not be published.


*