Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Minecraft Server Backup Script for Linux: Automate Your Backups

A practical Linux workflow for automated Minecraft backups: coordinate save-off/save-all, archive every world, schedule safely, retain generations, and verify restores.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A dependable Linux backup starts with a script that coordinates with Minecraft, archives every world, keeps more than one generation, and records failures. For an online backup, send save-off, run save-all (and save-all flush on Minecraft 1.16 or newer), wait for completion, archive the worlds, then always send save-on in a cleanup handler. Schedule that script with either cron or a systemd timer, store archives outside the live world directory, and perform a real extraction test before trusting a backup.

What the backup process must protect

A Minecraft server’s important state is not limited to one folder. The main world directory contains level.dat, region files, player data, advancements, and data packs. A typical installation also has separate folders for the Nether and the End, often named world_nether and world_the_end. Back up every active world folder, not just the directory named world.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The backup job should run as the same dedicated Linux account that owns the server files, normally a user such as minecraft. Using that account avoids archives owned by root that the server cannot later read. Use absolute paths because cron and systemd provide a smaller environment than an interactive shell.

  • Pause automatic saves before copying an online world.
  • Flush pending world and player writes.
  • Create a timestamped archive or restic snapshot.
  • Resume saving even if compression or storage fails.
  • Delete old generations according to a documented retention policy.
  • Write success and failure information to a log.

Online backups: the safe command sequence

The nicolaschan/minecraft-backup project documentation gives this order for an online backup and states: “Recommendation: Use RCON if possible for the safest backups.” RCON lets the script send commands and receive a completion response instead of guessing how long a save will take.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  1. save-off pauses the normal automatic save cycle.
  2. save-all flushes world and player data that is waiting to be written.
  3. On Minecraft 1.16 and newer, send save-all flush to force writes to disk. The project documents this command as harmless on older versions.
  4. Wait for the console client to report completion. With screen or tmux, use a delay long enough for the particular world and disk; a fixed delay is only a fallback.
  5. Archive each world directory.
  6. Run save-on from a shell cleanup trap so autosaving is restored after a successful archive, a failed archive, or an interrupted script.

This process reduces the chance of copying a region while it is being written, but it is not a transaction. The documentation warns that player-event saves can continue after save-off, so an online archive may still contain a timing mismatch between player data and world data. For the strongest consistency, announce a short maintenance window, stop the server cleanly, and copy the files while the process is down. If uptime requires an online copy, disclose the residual risk and verify the archive by restoring it.

A Bash script you can adapt

The following Linux script uses an RCON client command represented by mcrcon. Install and configure the RCON client you actually use, or replace the RCON array with your client and its options. Enable RCON in the server configuration, protect the password file, and never place the password in a world directory that will be archived.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#!/usr/bin/env bash
set -Eeuo pipefail

MC_HOME="/srv/minecraft"
BACKUP_DIR="/srv/minecraft-backups"
LOG_FILE="/var/log/minecraft-backup.log"
LOCK_FILE="/run/minecraft-backup.lock"
MAX_BACKUPS=24

# Change these values for your server and RCON client.
RCON=(/usr/local/bin/mcrcon -H 127.0.0.1 -P 25575 -p 'change-this-password')
WORLDS=(world world_nether world_the_end)

mkdir -p "$BACKUP_DIR"
exec >>"$LOG_FILE" 2>&1

# Prevent two scheduler invocations from archiving the same files.
exec 9>"$LOCK_FILE"
flock -n 9 || { echo "$(date -Is) backup already running"; exit 1; }

STAMP=$(date -u +%Y-%m-%dT%H-%M-%SZ)
ARCHIVE="$BACKUP_DIR/minecraft-$STAMP.tar.gz"

console() {
  "${RCON[@]}" "$1"
}

cleanup() {
  # Always re-enable automatic saving, including after tar or RCON errors.
  set +e
  console "save-on" >/dev/null 2>&1
}
trap cleanup EXIT

printf '%s backup startedn' "$(date -Is)"
console "save-off"
console "save-all"
console "save-all flush"

# Prefer an RCON completion response. This delay is only a conservative fallback.
sleep 5

tar -C "$MC_HOME" -czf "$ARCHIVE" "${WORLDS[@]}"
sha256sum "$ARCHIVE" > "$ARCHIVE.sha256"

# Keep the newest MAX_BACKUPS archives and remove older tarballs and checksums.
mapfile -t OLD < <(find "$BACKUP_DIR" -maxdepth 1 -type f -name 'minecraft-*.tar.gz' -printf '%T@ %pn' | sort -nr | tail -n +$((MAX_BACKUPS + 1)) | cut -d' ' -f2-)
for file in "${OLD[@]}"; do
  rm -f -- "$file" "$file.sha256"
done

printf '%s backup completed: %sn' "$(date -Is)" "$ARCHIVE"

Replace MC_HOME, the world list, the RCON endpoint, and the destination before installing the script as /usr/local/sbin/minecraft-backup. Set ownership and permissions so only the Minecraft account and administrators can read the script and its RCON secret. Test it interactively as that account before adding a scheduler.

The archive command stores paths relative to MC_HOME, so extraction recreates the expected world-folder names. If your server uses a custom level name or additional dimensions, add those directories to WORLDS. If you use restic instead of tar, keep the same save coordination and replace only the archive and retention portions.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Scheduling with cron

Cron is simple and available on almost every Linux distribution. The reference project includes an hourly cron arrangement. Edit the Minecraft user’s crontab with crontab -e and add:

17 * * * * /usr/local/sbin/minecraft-backup

Because the script redirects output to its log, cron only needs the command. If you prefer explicit redirection, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
17 * * * * /usr/local/sbin/minecraft-backup >> /var/log/minecraft-backup.log 2>&1

Choose a minute that does not collide with other intensive jobs, and ensure the destination has enough free space for at least the largest expected archive plus one additional generation. Cron does not provide dependency ordering; if the server is stopped during maintenance, the script must detect that condition or the operator must disable the entry.

Scheduling with a systemd timer

Systemd timers are useful when you want native logs, dependency ordering, missed-run handling, and one template per server. Create /etc/systemd/system/minecraft-backup.service:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
[Unit]
Description=Back up the Minecraft world
After=network-online.target

[Service]
Type=oneshot
User=minecraft
ExecStart=/usr/local/sbin/minecraft-backup

Then create /etc/systemd/system/minecraft-backup.timer:

[Unit]
Description=Hourly Minecraft backup timer

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target

Activate it with:

sudo systemctl daemon-reload
sudo systemctl enable --now minecraft-backup.timer
systemctl list-timers minecraft-backup.timer
journalctl -u minecraft-backup.service

Persistent=true tells systemd to run a missed calendar job once after the machine comes back, rather than silently losing that occurrence. The service's User=minecraft setting makes the execution identity explicit. For several servers, create a service template such as [email protected] and pass an instance-specific script or environment file, but keep each server's lock, log, and destination separate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cron or systemd: which scheduler fits?

Consideration Cron Systemd timer
Visibility Inspect the user's crontab and the script log. Use systemctl list-timers and journalctl for schedule and service history.
Dependency ordering No built-in ordering beyond the command itself. Units can require network, mounts, or another service.
Missed runs A job missed while powered off is normally lost. Persistent=true can run it after boot.
Per-server templating Separate crontab lines and configuration files are straightforward. Template units and drop-ins scale cleanly across servers.
Portability Available on systems with a cron daemon. Requires a systemd-based distribution.

Pick one scheduler for a given server. Running both creates overlapping archives, duplicate RCON commands, and confusing retention results.

Retention and storage design

Retention is what prevents a successful hourly job from eventually filling the backup disk. The reference script supports thin, sequential, and none deletion modes together with a maximum-backup setting. In practical terms, a thin policy removes older generations as the limit is reached, sequential naming preserves an ordered run of copies, and none leaves deletion to an external process. Whichever policy you select, document how many hourly, daily, and weekly copies must survive.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

A useful pattern is frequent short-term copies combined with less frequent long-term copies: for example, keep a day's worth of hourly archives, then retain selected daily archives for several weeks. The exact numbers depend on world size, change rate, and available storage; the important property is that the policy is finite and tested.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Destination Failure-domain benefit Trade-off
Same disk as the live world Fastest local restore. A disk failure, filesystem damage, or ransomware can remove both live data and backups.
External USB HDD or SSD Separates the archive from the server's internal disk; MCscripts documents linking an external drive as backup_dir. Requires connection, enough capacity, and a process for disconnecting or protecting the drive.
Off-host storage Survives loss of the entire machine or location. Uploads consume bandwidth, restores depend on network access, and ongoing cost and privacy requirements must be evaluated.

At least one generation should be on storage separate from the host. Keep permissions restrictive, and encrypt archives when the storage location is not fully under your control.

How to prove that a backup restores

A file that was created without an error is not automatically a usable backup. Test each policy after installation and repeat the test when you change Minecraft versions, storage, or the script.

  1. Choose an archive and create a new, empty test directory outside the production server path: mkdir -p /srv/minecraft-restore-test.
  2. Verify the checksum if you created one: sha256sum -c minecraft-YYYY-MM-DDTHH-MM-SSZ.tar.gz.sha256.
  3. Extract without touching the live world: tar -xzf minecraft-YYYY-MM-DDTHH-MM-SSZ.tar.gz -C /srv/minecraft-restore-test.
  4. Inspect level.dat, region files, player data, and the Nether and End directories. Check that the expected world names and timestamps are present.
  5. Start a temporary server instance against the extracted copy, or stop production and replace its world only after the test copy is confirmed. Never experiment by overwriting the only live directory.
  6. Record the result, the archive tested, and the time required to restore. A recovery procedure that no one has rehearsed is an assumption, not a plan.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

RCON, screen, and tmux choices

Method Save-completion acknowledgement Setup complexity Consistency risk
RCON Can return the server's response, allowing the script to wait for save completion. Requires enabling RCON, securing credentials, and configuring a client. Lowest of these options, but player-event saves can still create a timing mismatch.
screen Usually requires a tuned delay or parsing console output. Works when the server already runs in a screen session; command injection syntax must match the session. Higher if the delay is shorter than the save operation.
tmux Like screen, it generally needs a tuned delay unless you build output detection. Requires the correct session and window names. Higher than RCON when completion is inferred only from elapsed time.

Use RCON when possible. If screen or tmux is unavoidable, measure save times on the real world, choose a conservative delay, and retain the restore-testing discipline.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Troubleshooting failed or unsafe jobs

The archive is empty or missing a dimension

Check MC_HOME and the WORLDS array, then run tar -tzf archive.tar.gz to list its contents. A relative path error is common when a scheduler runs from a different working directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

save-on did not run

Confirm that the script is executable and that the trap is installed before the first RCON command. Check the log for authentication or connection errors. If the server is left with saving disabled, issue save-on manually through the console before allowing players back in.

Backups overlap

Keep the flock guard, use only one scheduler, and inspect systemd or cron logs for a second invocation. Large worlds may take longer to compress than the scheduling interval.

RCON commands time out

Verify the RCON port, password, bind address, firewall, and server configuration. Test each command interactively as the same Linux user. Do not silently fall back to copying files while the server is writing; either fix RCON or deliberately switch to a maintained screen/tmux procedure with a documented delay.

The disk fills up

Check the retention count, archive sizes, and destination mount with df -h. Make deletion part of the success path and alert on failures so a full disk does not go unnoticed. Move older generations to separate storage rather than deleting the only copies.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operational checklist

  • Run the script manually as the dedicated Minecraft user.
  • Confirm all world folders are included and the archive lists them.
  • Use RCON completion responses when available; otherwise tune a conservative delay.
  • Ensure the cleanup trap re-enables saving after every failure mode.
  • Choose cron or a systemd timer, not both.
  • Log exit status and review logs after the first several scheduled runs.
  • Keep finite retention and at least one copy on separate storage.
  • Perform and document extraction tests before calling the system reliable.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.