DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

Minecraft Server Backup Script for Linux: Automate Your Backups

Build a dependable Linux backup workflow for Minecraft: coordinate saves with RCON, archive every world, schedule hourly jobs, retain generations, and prove recovery with a test restore.
Length4 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A reliable Linux backup uses a Bash script that coordinates with the Minecraft console, writes a timestamped archive to storage outside the live world directory, removes old generations, and records failures. Run that script hourly with either cron or a systemd timer, and verify it by restoring an archive into a separate test directory.

For an online backup, pause automatic saves with save-off, flush data with save-all (and save-all flush on Minecraft 1.16 and newer), archive every world directory, then resume saving in a cleanup trap. The nicolaschan/minecraft-backup documentation recommends RCON when possible because it can acknowledge that saving has finished.

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.

What the backup must protect

A Minecraft server is more than the main world directory. A typical Java server also has world_nether and world_the_end, plus player data, advancements, statistics, the whitelist, operator lists, and server configuration. Back up the complete server state you need to recreate the instance, but do not copy the live directory into the backup destination while it is being modified.

The nicolaschan/minecraft-backup project is a useful reference implementation: it accepts world-folder inputs, can produce tar archives or a restic repository, and supports RCON, screen, tmux, Docker, and cron. Its restore model is deliberately simple: extract a known-good archive into a new directory, inspect it, and only then replace the production world.

#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.

Online backup or maintenance window?

Why save coordination matters

Copying files while the server is writing them can produce a set made from different moments in time. The safest procedure is to stop the server cleanly and copy the files while no process can change them. That requires a short maintenance window, but it gives the most consistent snapshot.

If the server must remain online, coordinate the save cycle:

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.
  1. Send save-off to pause automatic world saves.
  2. Send save-all to flush world and player data.
  3. On Minecraft 1.16 and newer, send save-all flush to force writes to disk. The reference script documents this command as harmless on older versions, so it can be enabled for mixed-version fleets.
  4. Wait for completion. RCON can provide an acknowledgement; screen and tmux generally require a delay tuned to the size and speed of the world.
  5. Create the tar or restic backup from each world directory.
  6. Send save-on in a cleanup trap so autosaving resumes even if archiving or retention fails.

Online coordination reduces the risk but does not eliminate it. The project documentation warns that player-event saves can continue after save-off, leaving player data and world data with a timing mismatch. Treat an online archive as a risk-managed snapshot, disclose that limitation to your players, and test restores. For irreplaceable worlds, stop the server cleanly before copying.

A Bash script that creates timestamped archives

Save the following as /usr/local/sbin/minecraft-backup and make it executable with sudo chmod 750 /usr/local/sbin/minecraft-backup. The script assumes the service account can read the server directory and write the backup destination. Set the RCON command for your client; the array shown uses the commonly available mcrcon syntax, but the same function can call another RCON client.

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.
#!/usr/bin/env bash
set -Eeuo pipefail

SERVER_DIR=/srv/minecraft
BACKUP_ROOT=/srv/minecraft-backups
KEEP=24
FLUSH=true
WORLDS=(world world_nether world_the_end)
STAMP=$(date -u +%Y-%m-%dT%H-%M-%SZ)
ARCHIVE=$BACKUP_ROOT/minecraft-$STAMP.tar.gz
RCON_PASSWORD=${RCON_PASSWORD:?Set RCON_PASSWORD in the service environment}
RCON=(/usr/bin/mcrcon -H 127.0.0.1 -P 25575)

mkdir -p $BACKUP_ROOT
mc() {
  "${RCON[@]}" -p $RCON_PASSWORD "$1"
}

cleanup() {
  if ! mc 'save-on'; then
    logger -t minecraft-backup 'could not re-enable automatic saving'
  fi
}
trap cleanup EXIT

mc 'save-off'
mc 'save-all'
if $FLUSH; then
  mc 'save-all flush'
fi
# Add a delay when your console transport does not acknowledge completion.
sleep 5

tar -C $SERVER_DIR -czf $ARCHIVE ${WORLDS[@]}

mapfile -t archives < <(find $BACKUP_ROOT -maxdepth 1 -type f -name 'minecraft-*.tar.gz' -printf '%T@ %pn' | sort -nr | cut -d' ' -f2-)
if (( ${#archives[@]} > KEEP )); then
  for old in "${archives[@]:KEEP}"; do
    rm -f -- $old
  done
fi
logger -t minecraft-backup "created $ARCHIVE"

Store the RCON password outside the script, for example in a root-readable environment file used by the service, and restrict that file to the Minecraft administrator. Replace the world list if your server uses a different level-name or additional dimensions. The archive command records paths relative to SERVER_DIR, so extraction recreates the expected directory names.

What each part does

  • Timestamp: UTC names sort predictably and avoid collisions between runs.
  • Cleanup trap: save-on runs when the script exits normally or after a failed archive, preventing a forgotten save-off from disabling autosaves indefinitely.
  • Retention: KEEP=24 retains the newest 24 tar files. Change it to match your disk capacity and recovery-point needs.
  • Exit status and logs: set -Eeuo pipefail makes command failures visible, while logger sends success and cleanup errors to the system journal.

If you prefer deduplicated, encrypted repository storage, adapt the archive step for restic instead of tar. The reference project supports both output styles; tar remains convenient for a transparent, one-file restore.

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

Schedule the script with cron

An hourly backup is a practical starting point for an active server. In /etc/crontab or a file under /etc/cron.d, use the account field explicitly:

0 * * * * minecraft flock -n /run/minecraft-backup.lock /usr/local/sbin/minecraft-backup >>/var/log/minecraft-backup.log 2>&1

The flock guard prevents a second run from starting while a large archive is still being written. Use absolute paths because cron supplies a minimal environment. If the script reads RCON_PASSWORD from a file, have the cron command load that file before invoking the script, or use a wrapper owned by the Minecraft administrator.

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.

Schedule it with a systemd timer

Systemd timers make dependencies, logs, and per-server instances easier to inspect. Create /etc/systemd/system/minecraft-backup.service:

[Unit]
Description=Minecraft server backup
After=minecraft.service

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

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[Unit]
Description=Hourly Minecraft backup

[Timer]
OnCalendar=hourly
Persistent=true
Unit=minecraft-backup.service

[Install]
WantedBy=timers.target

Enable and inspect 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 causes a missed calendar run to be started after the machine returns, rather than silently losing that interval. MCscripts provides Java and Bedrock backup services and timers, and ArchWiki references minecraftd-backup.timer; these are useful patterns when you manage several servers. Choose one scheduler per server, not both.

Cron versus a systemd timer

Consideration Cron Systemd timer
Scheduling visibility Inspect the crontab and command output systemctl list-timers shows the next and previous run
Dependency ordering Must be handled in the command or wrapper Unit relationships such as After=minecraft.service are explicit
Logging Redirect to a file or facility Integrated journal with exit status and timestamps
Missed runs Usually skipped while the host is off Persistent=true can run after boot
Per-server templating Simple separate lines, but environment handling is manual Template units and instance names scale cleanly

For a single traditional host, cron is minimal and dependable. For multiple instances, dependency control, or audit-friendly logs, a systemd timer is usually easier to operate.

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

RCON, screen, and tmux for console control

Transport Save-completion acknowledgement Setup complexity Residual consistency risk
RCON Can confirm that the command completed; preferred by the reference documentation Requires enabling RCON and protecting its password Player-event saves can still occur after save-off
screen Usually no structured completion response; use a tuned delay Works when the server already runs in a screen session Higher if the delay is too short or the console command is lost
tmux Usually no structured completion response; use a tuned delay Works when the server already runs in a tmux session Higher if the delay is too short or the console command is lost

Use RCON when possible. If screen or tmux is unavoidable, measure how long save-all takes on your world under normal load and add a safety margin before archiving. A fixed delay is not proof that all writes completed.

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

Retention and storage design

Keep generations deliberately

A backup directory without retention eventually fills the disk and can stop the server. The reference script supports thin, sequential, and none deletion modes together with a maximum-backup setting. A practical policy keeps frequent short-term copies, then fewer long-term copies—for example, hourly files for a day and selected daily files for several weeks. Implement the policy with separate jobs or a retention tool rather than deleting the only copy after a failed run.

Separate the failure domain

Do not place the only archive beside the live world on the same filesystem. A failed disk, accidental deletion, ransomware event, or filesystem corruption can destroy both. MCscripts documents linking an external drive as backup_dir; an external USB hard drive or SSD is therefore a straightforward destination. Keep at least one generation on storage that is physically separate from the host. An off-host copy provides stronger failure-domain separation, but requires network bandwidth, credentials management, privacy controls, and ongoing storage cost.

Destination Failure-domain separation Restore bandwidth Privacy and cost considerations
Second local disk Protects against a failure of the primary disk, not theft or host-wide damage Fast local restore One-time hardware cost; access stays under your control
External USB HDD or SSD Can be disconnected or moved away from the host Fast when attached Requires rotation, protection from loss, and enough capacity
Off-host storage Best separation from a destroyed host or site Depends on upload and download capacity Recurring cost, account security, and jurisdiction/privacy choices
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to verify and restore a backup

A successful tar command proves only that an archive was created. It does not prove the archive contains a usable world. Test every backup generation on a schedule, and test immediately after changing the script or server version.

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.
  1. Create a new, empty restore directory outside the production path: mkdir -p /srv/minecraft-restore/test-2026-10-15.
  2. List the archive before extraction: tar -tzf /srv/minecraft-backups/minecraft-YYYY-MM-DDTHH-MM-SSZ.tar.gz. Confirm that all expected world directories are present.
  3. Extract into the test directory: tar -xzf /srv/minecraft-backups/minecraft-YYYY-MM-DDTHH-MM-SSZ.tar.gz -C /srv/minecraft-restore/test-2026-10-15.
  4. Inspect region files, player data, level metadata, and the directory names. Check ownership and permissions before starting a test server.
  5. Run a separate test instance on the extracted files, join with an administrator account, and verify terrain, inventories, and recent changes.
  6. Only after the test succeeds, stop the production server, preserve the current directory as a rollback copy, and replace it with the restored directory.

The reference documentation explicitly advises testing backups and provides tar extraction as the restore method. Keep the failed or replaced production directory until the restored server has been observed through at least one normal save cycle.

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

Troubleshooting common failures

The server remains in read-only save mode

Check the journal or cron log for an RCON authentication error, a missing client binary, or a trap that could not connect. Send save-on manually through the console, then fix credentials and permissions before the next run. The cleanup trap cannot help if the console transport itself is unavailable.

The archive is missing a dimension

Compare the configured WORLDS array with the server's actual level-name and dimension directories. A custom level name or a proxy-managed world path must be listed explicitly. Run tar -tzf during verification so omissions are detected before an emergency restore.

Backups overlap or disk usage spikes

Keep the flock guard, monitor archive duration, and lower the schedule frequency if the world cannot be archived within the interval. Confirm that retention runs after a successful archive and that the backup destination has free space. Never delete the newest known-good generation merely to make room for a partial file.

The restore starts but rolls back recent activity

This is expected when restoring an older generation. Record the archive timestamp and communicate the recovery point to players. If an online backup shows inconsistent player data, use a maintenance-window backup for the authoritative restore instead.

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 job as the dedicated minecraft user, with absolute paths.
  • Use RCON where possible; protect its credentials and verify command completion.
  • Include every world directory and the server data needed to recreate the instance.
  • Use a cleanup trap that always attempts save-on.
  • Retain several generations and keep at least one copy on separate storage.
  • Capture exit status in cron output or the system journal.
  • Perform a real extraction and test-server restore, not just an archive listing.

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 *

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

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.