snapshot.sh script performs a nightly world backup. It broadcasts an
in-game countdown before stopping the server, takes a compressed snapshot, and
restarts automatically. Snapshots older than 7 days are deleted as part of the
same run.
Snapshot behavior
When the cron job fires:-
If the server is online, a 30-minute countdown begins. In-game chat
warnings with an audible alert are broadcast at the following intervals:
Time remaining Message 30 minutes ”The server will go down for a daily snapshot in 30 minutes.” 15 minutes ”The server will go down for a daily snapshot in 15 minutes.” 10 minutes ”The server will go down for a daily snapshot in 10 minutes.” 5 minutes ”The server will go down for a daily snapshot in 5 minutes.” 1 minute ”The server will go down for a daily snapshot in 1 minute!“ 30 seconds ”Server going down for snapshot in 30 seconds! Please log off now.” 15 seconds ”Server going down for snapshot in 15 seconds!“ 5 seconds ”Server going down for snapshot in 5 seconds!” -
The
stopcommand is sent to the server console. If the server does not exit within 30 seconds, it is force-killed. -
A
.tar.gzsnapshot is saved tobackups/containing:- All world directories (
world,world_nether,world_the_end, and any others matching theworld*prefix) whitelist.jsonserver.properties
- All world directories (
- The server is automatically restarted.
-
Any snapshot files older than 7 days are deleted from the
backups/directory.
Cron setup
Open the root crontab
The snapshot script must run as root (or the user owning the server
directory) to have permission to stop the server and write backup files:
Add the cron entry
Add the following line to schedule the snapshot every night at 11:30 PM:Output is appended to a log file so you can review past runs.
Checking snapshot logs
To watch the log in real time during a snapshot run:Snapshot archive naming
Snapshot files follow the patternsnapshot_YYYYMMDD_HHMMSS.tar.gz and are
stored in:
serv restore.