Skip to main content
The 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:
  1. If the server is online, a 30-minute countdown begins. In-game chat warnings with an audible alert are broadcast at the following intervals:
  2. The stop command is sent to the server console. If the server does not exit within 30 seconds, it is force-killed.
  3. A .tar.gz snapshot is saved to backups/ containing:
    • All world directories (world, world_nether, world_the_end, and any others matching the world* prefix)
    • whitelist.json
    • server.properties
  4. The server is automatically restarted.
  5. Any snapshot files older than 7 days are deleted from the backups/ directory.
If the server is offline when the cron fires, the countdown is skipped entirely and the snapshot is taken immediately.

Cron setup

The snapshot script takes 30 minutes to complete its countdown before stopping the server. Schedule the cron job at 11:30 PM — not midnight — so the server actually goes down at midnight. Scheduling at midnight means the server won’t stop until 12:30 AM.
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:
Example log output from a successful run:

Snapshot archive naming

Snapshot files follow the pattern snapshot_YYYYMMDD_HHMMSS.tar.gz and are stored in:
They can be restored interactively at any time with serv restore.