Sign in to follow this  
Darkness1990

Server backup Batch file

Recommended Posts

Hi guys, thought I would share this server_backup.bat I created. 

 

How to setup

1. Copy/paste the code into a text document and save as "server_backup.bat" 
2. Change the "password" to your servers intra password

3. Create a folder called "Backups" somewhere in your server folder.

4. Create a folder called "Purgefiles" somewhere in your Backups folder.

5. Change the paths to your wurm server folders.

6. Download and unzip RMITool to where ever you like (Just not your mods folder) Bdews post here: RMITool download

7. Download and install sqlite3 files into a new folder in c:\sqlite3 or where you you like. Link to sqlite3 Download
8. Setup sqlite3. Video of how to do it here: Example video
9. Follow the same steps in the video above after you install winrar. Create a new environment variable for winrar, just point the path to where you installed winrar.

 

 

 

Then just run the batch file, it will create a backup while the server is running and compress and date the files and delete any old backups. Change the minage:14 to whatever you like.

 

For automatic backups you can setup Task Scheduler to run the batch file whenever you like! Enjoy I hope this helps some of you. :)

 

 

Spoiler

@echo off
REM - WARN USERS - PATH TO RMITOOL FOLDER
CD C:\Wurmserver\
java -jar rmitool.jar 127.0.0.1 7120 password broadcast "Server backup has started..."
 
REM - GET TIMESTAMPS
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
SET "datestamp=%mydate%_%mytime%"
echo datestamp: "%datestamp%"
 
REM - MAKE TEMP DIRECTORIES - PATH TO YOUR WURM SERVER BACKUP FOLDER
MKDIR "c:\Wurmserver\Backups\%datestamp%"
MKDIR "c:\Wurmserver\Backups\%datestamp%\sqlite"
 
REM - COPY DATABASES OVER - PATH TO YOUR WURM SERVER SQLITE FOLDER
CD  d:\Wurmserver\mapfolder\sqlite
FOR /R %%F in (*.db) do (
 echo %%~nF
 sqlite3 "%%F" ".backup 'C:\Wurmserver\Backups\%datestamp%\sqlite\%%~nF.db'"
)
 
REM - COPY MAPS OVER - PATH TO YOUR WURM SERVER MAP FOLDER
CD d:\Wurmserver\mapfolder

 

REM - PATH TO YOUR WURM SERVER BACKUP FOLDER
xcopy *.MAP c:\Wurmserver\Backups\%datestamp%\
xcopy protectedTiles.bmap "C:\Wurmserver\Backups\%datestamp%\"
 
REM - MOVE OLD FILES - PATH TO YOUR WURM SERVER BACKUP FOLDER
rar.exe a -ep1 -dw "c:\Wurmserver\Backups\%datestamp%.rar" "C:\Wurmserver\Backups\%datestamp%"
 
REM - MOVE OLD FILES - PATH TO YOUR WURM BACKUP FOLDER AND PURGEFILES FOLDER
ROBOCOPY /S c:\Wurmserver\Backups C:\Wurmserver\Backups\Purgefiles /move /minage:14
 
REM - DELETE OLD FILES - PATH TO YOUR WURM SERVER PURGEFILES FOLDER
del C:\Wurmserver\Backups\Purgefiles /q
 
REM - WARN USERS - PATH TO RMITOOL FOLDER
CD c:\Wurmserver\
java -jar rmitool.jar 127.0.0.1 7120 password broadcast "Server backup complete!"
 
@echo on
pause

 

 

Edited by Darkness1990

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this