Run Your Own Rust Server Without Maintenance

RustRust is a fascinating game that has captured the hearts of tens of thousands of players. One of the neatest features is the ability to host one's own server on a low-end computer over a home internet connection.

This is a general how-to on starting a Rust server and automating the maintenance of it. SAPLSMW.com sponsors the Salty Misanthrope Rust server and it has its own webpage that can be found at this link.

In order to make hosting easy and maintenance-free, this programmer wrote batch files and VB scripts that handle the day-to-day upkeep of the server. The only requirement is to manually change the map settings on the first Thursday of the month and even that isn't required.

Rust2Obtain the software

Before building the server and running this batch file, it is first necessary to download and install the SteamCMD software. It can be obtained at this website.

The first batch file automatically downloads and installs the most recent version of Rust and then launches the dedicated Rust server program. When the program exits, the batch creates a backup of the server folder and maintains eight days worth of backups.

This batch installs and runs the Salty Misanthrope from drive D:, but your server might be on another drive, so some minor customization might be necessary. Replace [anything in brackets] with your server's information and save this as something like "rustserver.bat".

REM ***** This is the rustserver.bat file. *****
:start

d:

REM *** Check for updates every time the server restarts. ***
cd \steam
steamcmd +login anonymous +force_install_dir d:\rust +app_update 258550 +quit

REM *** Start the Rust server with high thread priority. ***
cd \Rust
start /wait /high RustDedicated.exe -batchmode +server.level "Procedural Map" +server.seed 3746 +server.worldsize 3700 +server.maxplayers 25 +server.hostname "[Put the name of your server here]" +server.description "[Put a nice long description of your server here.  The \n is used to start a new line.]" +server.url "http://yourserver.goes.here" +server.headerimage "https://your.custom/image.jpg" +server.identity "9999999" +rcon.ip 127.0.0.1 +rcon.port 28016 +rcon.password [StrongServerPassword] +nav_disable false +decay.upkeep_period_minutes "14400"

REM *** Back up the server 8 iterations. ***
md d:\temp
erase d:\temp\rust.008 /q /s /f
rd d:\temp\rust.008 /q /s
rename d:\temp\rust.007 rust.008
rename d:\temp\rust.006 rust.007
rename d:\temp\rust.005 rust.006
rename d:\temp\rust.004 rust.005
rename d:\temp\rust.003 rust.004
rename d:\temp\rust.002 rust.003
rename d:\temp\rust.001 rust.002
rename d:\temp\rust rust.001
md d:\temp\rust
xcopy d:\rust d:\temp\rust /s/e/c/d/h/i/y
start /low /min cmd /c compact /c /q /s d:\temp\rust\*.*

REM *** Give the operator time to kill the batch after global.quit. ***
ping -n 30 localhost

goto :start

Configure the router

Be sure to point the ports 28015 and 28016 to your Rust server in the NAT settings of your router. Turn off the firewall of the Rust server if it still doesn't work.

RustEliminating chores . . .

Next, the daily restart for maintenance is called. This batch file (called restart.bat) calls a VB script which is listed below.

The title on the window that runs the server is "Dedicated Rust Server" because I named the shortcut in StartUp with that name. The script below uses that to set focus on that window before sending any keystrokes.

REM ***** This is the restart.bat file. *****
d:
cd \rust
wscript restart.vbs
exit

Finally, the daily maintenance script brings the Dedicated Rust Server window to the foreground and announces for half an hour that the server is being taken down just long enough for maintenance. The global.quit causes the Rust server to shut down and the "rustserver.bat" performs the backup along with any necessary updates before launching the server again.

'***** this is the restart.vbs file. *****
'* Script to gracefully shutdown rust server. 
'* Be sure to replace "Dedicated Rust Server" with the name of your window.

dim ObjShell :Set ObjShell = CreateObject("Wscript.Shell")
ObjShell.AppActivate("Dedicated Rust Server")
WScript.Sleep 1000
ObjShell.SendKeys "say ""Server rebooting in 30 minutes for daily maintenance."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 600000
ObjShell.SendKeys "say ""Server rebooting in 20 minutes for daily maintenance."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 300000
ObjShell.SendKeys "say ""Server rebooting in 15 minutes for daily maintenance."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 300000
ObjShell.SendKeys "say ""Server rebooting in 10 minutes for daily maintenance."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 300000
ObjShell.SendKeys "say ""Server rebooting in 5 minutes for daily maintenance."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 60000
ObjShell.SendKeys "say ""Server rebooting in 4 minutes for daily maintenance."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 60000
ObjShell.SendKeys "say ""Server rebooting in 3 minutes for daily maintenance. The server will be down 20 minutes."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 60000
ObjShell.SendKeys "say ""Server rebooting in 2 minutes for daily maintenance. The server will be down 20 minutes."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 60000
ObjShell.SendKeys "say ""Server rebooting in 1 minute for daily maintenance. The server will be down 20 minutes."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 30000
ObjShell.SendKeys "say ""Server rebooting in 30 seconds for daily maintenance. The server will be down 20 minutes."""
ObjShell.SendKeys "{ENTER}"
WScript.Sleep 30000
ObjShell.SendKeys "global.quit"
WScript.Sleep 1000
ObjShell.SendKeys "{ENTER}"

Rust3A strong recommendation here is to set the server's BIOS such that the server will turn itself on after a power outage. Additionally, AutoAdminLogon can be used to automatically log in the account that runs the Rust server and, if the "rustserver.bat" file is in the StartUp folder then the system will automatically come back online after a power outage.

All that remains is to program the daily maintenance batch file to run each day when the least amount of traffic is expected. 6PM was chosen here as all of the updates are typically released by then on the first Thursday of the month.

Be sure to use the login ID that runs the dedicated Rust server. Since the server is always running and logged in with the user, the "Run only when user is logged in" is moot, but it is still nice to leave it checked.




Rust2