Palworld – Basic Backup Script to Run on Windows Dedicated Servers

Basic Backup Script

After struggling with a corrupted save yesterday, I made a simple script to make backups of my dedicated server save.

Probably this will be useful only for people that run Windows homemade servers, but here’s the script:

u/echo off
setlocal enabledelayedexpansion

rem Set origin and destination folders
set "origin=YOUR_PALWORLD_SERVER_PATH"
set "destination=YOUR_BACKUP_FOLDER_PATH"

rem Calculate the cutoff date for backups (7 days ago)
for /f "tokens=1-5 delims=/: " %%d in ("%date% %time%") do (
    set /a "yy=10000+%%d, mm=100+%%e, dd=100+%%f, HH=100+%%g, MM=100+%%h"
)
set "cutoff=!yy!!mm!!dd!_!HH!!MM!"

rem Create backup folder name
set "backup_folder=!yy:~1,4!!mm:~1,2!!dd:~1,2!_!HH:~1,2!!MM:~1,2!"

rem Copy files to destination folder
xcopy "%origin%" "%destination%\%backup_folder%\" /E /I /Y > nul

rem Delete files older than 7 days (or keep the last 168 backups)
for /f "skip=168 delims=" %%F in ('dir /b /ad-h /o-d "%destination%"') do (
    if "%%F" LSS "%cutoff%" (
        rd /s /q "%destination%\%%F"
    )
)

endlocal

Change YOUR_PALWORLD_SERVER_PATH and YOUR_BACKUP_FOLDER_PATH with your respective folder paths. I suggest backing up just the “SaveGames” folder.

Save your file in .bat format and run it once to check if it works. Then setup a task to run it in Windows Task Scheduler, I run it every hour, the script should delete files older than one week.

Volodymyr Azimoff
About Volodymyr Azimoff 13822 Articles
I love games and I live games. Video games are my passion, my hobby and my job. My experience with games started back in 1994 with the Metal Mutant game on ZX Spectrum computer. And since then, I’ve been playing on anything from consoles, to mobile devices. My first official job in the game industry started back in 2005, and I'm still doing what I love to do.

Be the first to comment

Leave a Reply

Your email address will not be published.


*