Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Bash

Automatic Minecraft Bedrock Server Backup Script for Linux

By Freedom251 Team · · 8 min read

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.

The safest Linux backup is a scheduled job that identifies the world from server.properties, pauses writes by stopping the Bedrock service, creates a timestamped archive outside the live server directory, verifies that archive, and removes only backups older than your retention policy. The systemd-based example below works on Ubuntu 22.04 LTS or later and can be adapted to cron.

What you need before automating backups

Mojang’s current download guidance requires Ubuntu 22.04 LTS or later for the Linux Bedrock Dedicated Server. Microsoft’s getting-started documentation identifies Ubuntu as the supported Linux distribution family and documents launching the server with LD_LIBRARY_PATH=. ./bedrock_server from the extracted server directory.

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.
  • A running Bedrock Dedicated Server installed in a known directory, such as /srv/minecraft-bedrock.
  • A systemd service that can start and stop that server, for example minecraft-bedrock.service.
  • A backup destination outside the live server tree, such as /mnt/backups/minecraft-bedrock or a mounted external USB hard drive or SSD.
  • Root access, or an account with permission to stop the service, read the world, write the backup directory, and restore ownership.
  • Enough free space for at least one complete compressed archive plus a temporary archive.

On first launch, Bedrock creates a worlds directory. The active world directory is derived from the level-name value in server.properties; it is not necessarily called world. Shared behavior_packs and resource_packs directories may also be created. A useful backup therefore includes the active world, the server properties, permissions and allowlist files, and any packs or project-specific files required to recreate the server.

Choose how the backup gets a consistent snapshot

Controlled stop: the dependable default

Stopping the service before copying guarantees that Bedrock is not writing chunks, player data, or level metadata while tar reads the files. It briefly makes the server unavailable, but it does not depend on a particular console, multiplexer, RCON implementation, or third-party command sender. The script in this article uses this method.

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

save hold: shorter interruption when you have console control

Bedrock supports the console sequence save hold, archive the files, then save resume. This asks the running server to pause saves while the archive is made. Use it only when your service has a reliable way to send commands to the Bedrock console, such as the terminal multiplexer or management interface you already operate. Your cleanup handler must always attempt save resume, including after an archive or disk-space failure. Do not assume that a shell command written to standard input will reach a daemon started by systemd.

Decision Controlled stop save hold
Consistency Process is stopped; the filesystem is quiescent. Writes are paused by the server command.
Downtime From stop until the archive completes and the service restarts. Usually shorter, depending on archive size.
Requirements A working systemd service. A tested command channel to the Bedrock console.
Failure recovery Restart the service in an exit trap. Always issue save resume in cleanup, then restart or verify the process.

A robust shell script

Save the following as /usr/local/sbin/minecraft-bedrock-backup, then make it executable with chmod 750 /usr/local/sbin/minecraft-bedrock-backup. Change the four configuration values at the top to match your host. The script uses flock so overlapping timer runs cannot create competing archives.

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

SERVER_DIR='/srv/minecraft-bedrock'
BACKUP_DIR='/mnt/backups/minecraft-bedrock'
SERVICE='minecraft-bedrock.service'
RETENTION=7
LOCK_FILE='/run/lock/minecraft-bedrock-backup.lock'

mkdir -p "$BACKUP_DIR" "$(dirname "$LOCK_FILE")"
exec 9>"$LOCK_FILE"
flock -n 9 || { echo 'A backup is already running' >&2; exit 1; }

if [[ "$BACKUP_DIR" == "$SERVER_DIR" || "$BACKUP_DIR" == "$SERVER_DIR"/* ]]; then
    echo 'BACKUP_DIR must be outside SERVER_DIR' >&2
    exit 1
fi

PROPERTIES="$SERVER_DIR/server.properties"
[[ -r "$PROPERTIES" ]] || { echo "Missing $PROPERTIES" >&2; exit 1; }

LEVEL_NAME="$(awk -F= '$1 == "level-name" { sub(/r$/, "", $2); print $2; exit }' "$PROPERTIES")"
[[ -n "$LEVEL_NAME" ]] || { echo 'level-name is missing or empty' >&2; exit 1; }
[[ "$LEVEL_NAME" != /* && "$LEVEL_NAME" != *'..'* && "$LEVEL_NAME" != */* ]] || {
    echo 'Refusing an unsafe level-name' >&2
    exit 1
}

WORLD_REL="worlds/$LEVEL_NAME"
[[ -d "$SERVER_DIR/$WORLD_REL" ]] || { echo "World directory not found: $SERVER_DIR/$WORLD_REL" >&2; exit 1; }

ITEMS=("$WORLD_REL" 'server.properties')
for item in permissions.json allowlist.json ops.json behavior_packs resource_packs; do
    [[ -e "$SERVER_DIR/$item" ]] && ITEMS+=("$item")
done

WAS_ACTIVE=0
finish() {
    rc=$?
    if (( WAS_ACTIVE )); then
        systemctl start "$SERVICE" || { echo "Could not restart $SERVICE" >&2; rc=1; }
    fi
    [[ -n "${TMP_ARCHIVE:-}" ]] && rm -f -- "$TMP_ARCHIVE"
    exit "$rc"
}
trap finish EXIT INT TERM

if systemctl is-active --quiet "$SERVICE"; then
    WAS_ACTIVE=1
    systemctl stop "$SERVICE"
fi

STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
FINAL_ARCHIVE="$BACKUP_DIR/bedrock-$STAMP.tar.gz"
TMP_ARCHIVE="$BACKUP_DIR/.bedrock-$STAMP.partial"

tar -czf "$TMP_ARCHIVE" -C "$SERVER_DIR" "${ITEMS[@]}"
tar -tzf "$TMP_ARCHIVE" > /dev/null
chmod 600 "$TMP_ARCHIVE"
mv -- "$TMP_ARCHIVE" "$FINAL_ARCHIVE"
TMP_ARCHIVE=''

mapfile -t OLD < <(find "$BACKUP_DIR" -maxdepth 1 -type f -name 'bedrock-*.tar.gz' -printf '%T@ %pn' | sort -nr | awk -v keep="$RETENTION" 'NR > keep { sub(/^[^ ]+ /, ""); print }')
for archive in "${OLD[@]}"; do
    rm -f -- "$archive"
done

echo "Created $FINAL_ARCHIVE"

The archive is built with paths relative to SERVER_DIR, so extracting it back into that directory recreates worlds/<level-name> and the selected files. The temporary filename prevents a partially written archive from looking like a valid backup. tar -tzf checks that the completed gzip stream and its index can be read before the file is renamed. The retention value is a policy, not a Bedrock requirement. Seven nightly archives is one example used by a 2026-indexed Caramania.ca tutorial; choose a number from your world size, change rate, available storage, and recovery-point objective.

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.

Schedule it with systemd

A service and timer provide status, journal logs, dependency ordering, and a clean place to add restore or maintenance operations.

Backup service

[Unit]
Description=Back up Minecraft Bedrock data
RequiresMountsFor=/mnt/backups/minecraft-bedrock
After=minecraft-bedrock.service

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

Save it as /etc/systemd/system/minecraft-bedrock-backup.service. The RequiresMountsFor line makes systemd wait for the backup mount; without it, a disconnected external disk could result in archives being written to an ordinary empty directory on the root filesystem.

Daily timer

[Unit]
Description=Nightly Minecraft Bedrock backup timer

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target

Save this as /etc/systemd/system/minecraft-bedrock-backup.timer, then activate it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft-bedrock-backup.timer
systemctl list-timers minecraft-bedrock-backup.timer
sudo systemctl start minecraft-bedrock-backup.service
sudo journalctl -u minecraft-bedrock-backup.service -n 100 --no-pager

Persistent=true runs a missed timer after the host comes back online. Test a manual run before relying on the schedule; confirm that the service stops, an archive appears on the intended filesystem, and Bedrock starts again.

Cron is adequate for a minimal installation

If you already manage the server with cron and do not need timer status, use a root crontab entry:

sudo crontab -e
0 3 * * * /usr/local/sbin/minecraft-bedrock-backup >> /var/log/minecraft-bedrock-backup.log 2>&1

Cron has fewer moving parts, but you must arrange log rotation and inspect the log yourself. The locking and restart behavior still come from the script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Put backups somewhere a disk failure cannot erase them

Separate local filesystem

A second internal disk or mounted volume protects against accidental deletion in the live server directory and makes retention predictable. It does not protect against a failed host, filesystem corruption affecting both disks, theft, or ransomware.

External USB storage

An external USB hard drive or SSD can be mounted at /mnt/backups/minecraft-bedrock. Ensure it is mounted before the timer runs, give the service account access, and use RequiresMountsFor as shown above. Keep the drive disconnected or read-only when it is not receiving a backup if your threat model includes destructive malware.

Off-site copy

Copy verified archives to another host or storage service after the local job completes. The local script does not establish encryption, transfer authentication, or provider availability; those should be implemented and tested separately. Never treat an archive as recoverable until you have extracted it successfully.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Restore a Bedrock world safely

Restoration is a controlled replacement, not merely an extraction. Stop the service first so it cannot rewrite files while you restore.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Choose the archive and check it is readable: tar -tzf /mnt/backups/minecraft-bedrock/bedrock-YYYYMMDDTHHMMSSZ.tar.gz > /dev/null.
  2. Stop Bedrock: sudo systemctl stop minecraft-bedrock.service.
  3. Preserve the current world and configuration rather than deleting them. For example, rename worlds/<level-name> to worlds/<level-name>.before-restore and copy server.properties, permissions.json, and allowlist.json to a dated quarantine directory.
  4. Extract the archive into the server directory: sudo tar -xzf /mnt/backups/minecraft-bedrock/bedrock-YYYYMMDDTHHMMSSZ.tar.gz -C /srv/minecraft-bedrock.
  5. Restore the ownership and permissions expected by the service account. A common pattern is sudo chown -R minecraft:minecraft /srv/minecraft-bedrock; substitute the actual account and group used by your unit.
  6. Start Bedrock and inspect its log: sudo systemctl start minecraft-bedrock.service, followed by sudo journalctl -u minecraft-bedrock.service -n 100 --no-pager.
  7. Connect as a player, confirm the expected world, packs, permissions, and allowlist, and only then remove the quarantined files.

For a restore helper managed by a higher-level tool, follow that tool’s documented order: stop the service, run its restore operation, then start the service. The order matters because restoring into a live process can produce a mixed world state.

Common failures and fixes

  • The wrong world is archived: inspect server.properties and verify the exact level-name; do not hard-code world unless that is the configured value.
  • The archive is empty or written to the root disk: check the external mount with findmnt /mnt/backups/minecraft-bedrock and confirm the systemd mount dependency.
  • The service does not restart: run systemctl status minecraft-bedrock.service and inspect journalctl. Correct the unit, executable path, or ownership before the next scheduled run.
  • Permission denied: run the timer as root or grant the service account read access to the server and write access to the backup mount. Keep archives mode 600 because they contain player data and server configuration.
  • Backups consume all storage: measure archive sizes, set a retention count that fits the destination, and add monitoring for free space. Retention alone does not create off-site redundancy.
  • Concurrent runs appear in logs: leave the flock lock in place and investigate unusually long archive times rather than removing the lock.
  • A restore starts but the world is missing: list the archive contents and compare its worlds/ path with the current level-name. The archive and configuration must agree.

Which operating model fits your server?

Approach Best fit Trade-off
Custom shell script with cron One server and an administrator comfortable checking logs. Smallest setup, but logging, alerts, and mount ordering are your responsibility.
Custom shell script with systemd timer Servers where status, journal history, dependency ordering, and repeatable restores matter. Slightly more configuration than cron.
Bedrock Server Manager Operators who want a management interface with scheduled tasks, automatic backup, pruning, and update handling. Less shell maintenance, but behavior and restore procedures depend on the manager’s version and configuration.

Pre-flight checklist

  • Confirm the host is running Ubuntu 22.04 LTS or later and launch behavior matches the documented LD_LIBRARY_PATH=. ./bedrock_server command.
  • Run the script manually while watching the service status.
  • Confirm the archive contains the active world, server.properties, permissions or allowlist files, and required packs.
  • Confirm the destination is outside the live server tree and is mounted before scheduling.
  • Record archive size and completion time so retention and the maintenance window are based on measurements.
  • Perform a test restore to a separate directory or host before calling the backup strategy 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.

BashCronDisaster RecoveryLinuxMinecraft Bedrockserver backupsystemdUbuntu

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.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.