# vi backup.sh
---------------- file contents ----------
#!/bin/bash
####################################
#
# Backup Palworld Saved games to a
# specified folder.
#
####################################
# What to backup.
backup_files="/home/steam/palworld/Pal/Saved"
backup_file_name="palworld"
# Specify which directory to backup to.
# Make sure you have enough space to hold {n} days of backups.
dest="/home/steam/backups"
# Create backup archive filename.
day=$(date +"%Y-%m-%d_%H-%M-%S")
archive_file="$day-$backup_file_name.tar.gz"
# Stop Palworld Server
systemctl stop palworld
# Backup the files using tar.
tar zcvf $dest/$archive_file $backup_files
# Clear backups
/home/steam/clear_backups.sh
# Start Palworld Server
systemctl start palworld
---------------- end file contents ----------
# chmod +x backup.sh
# vi clear_backups.sh
---------------- file contents ----------
#!/bin/bash
####################################
#
# Clean up Palworld saved game to a
# specified folder.
#
####################################
# -mtime +30 means any file older than 30 days
find /home/steam/backups -type f -mtime +30 -exec rm -f {} \;
---------------- end file contents ----------
# chmod +x clear_backups.sh
# crontab -l
0 3 * * * /home/steam/backup.sh
Restoring a backup:
E.g.
# Stop Palworld Server
systemctl stop palworld
# Remove existing data
mv /home/steam/palworld/Pal/Saved /home/steam/palworld/Pal/SavedOLD
rm -rf /home/steam/palworld/Pal/Saved/*
# Restore a saved file.
tar -xvf /home/steam/backups/2021-02-18_03-00-01-palworld.tar.gz -C /
# Restore permissions on files
chown steam:steam -R /home/steam/palworld/Pal/Saved
# Start Palworld Server
systemctl start palworld