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:
-
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
1
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:
2
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.
3
Verify the entry was saved
Confirm the cron entry is present:
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.