This collection of bash scripts provides comprehensive management for a Minecraft Bedrock server on Linux, including automated updates, backups, and server control.
- Automated Updates: Download and install the latest Minecraft Bedrock server
- Backup System: Automatic backups before updates with configurable retention
- Screen Management: Server runs in a screen session accessible by both
mcserveruser and root - Graceful Shutdown: Player warnings before server stops
- Configuration Preservation: Keeps server settings and world data during updates
- System Integration: Optional systemd service and firewall configuration
Initial setup script that prepares the environment:
- Creates the
mcserveruser - Sets up directories with proper permissions
- Configures screen for multi-user access
- Creates systemd service
- Sets up firewall rules (if UFW is available)
- Creates helpful command aliases
Configuration file containing all customizable settings:
- Server paths and directories
- Backup retention settings
- Download URLs
- User and session names
Downloads and installs the latest Minecraft Bedrock server:
- Automatically detects the latest version from minecraft.net
- Falls back to configured URL if detection fails
- Downloads the latest server version
- Creates backups before updating
- Preserves world data and configuration files
- Gracefully stops/starts the server
- Cleans up old backups
Version checking utility:
- Compares installed version with latest available
- Shows detailed server information
- Supports automated version monitoring
- Useful for scripting and monitoring
Starts the Minecraft server in a screen session:
- Checks for existing running instances
- Starts server as
mcserveruser - Creates screen session accessible by root
- Provides connection instructions
Gracefully stops the Minecraft server:
- Sends warnings to players (60s, 15s, 5s countdown)
- Saves world data before stopping
- Supports force stop option
- Shows server status after stopping
Comprehensive management interface:
- Shows detailed server status
- Connects to server console
- Sends commands to running server
- Provides shortcuts for start/stop/restart operations
-
Clone or download the scripts to your preferred location:
cd /path/to/scripts -
Edit the configuration in
config.shif needed:nano config.sh
-
Run the setup script as root:
sudo ./setup.sh
-
Download and install the server:
sudo ./update-server.sh
-
Start the server:
./start-server.sh
Edit config.sh to customize:
# Server configuration
SERVER_USER="mcserver" # User to run the server
SERVER_DIR="/home/mcserver/minecraft-server" # Server installation directory
BACKUP_DIR="/home/mcserver/backups" # Backup storage directory
SCREEN_SESSION_NAME="minecraft-server" # Screen session name
# Download URL (update this for newer versions)
DOWNLOAD_URL="https://minecraft.azureedge.net/bin-linux/bedrock-server-1.21.44.01.zip"
# Backup retention
BACKUP_RETENTION_DAYS=30 # Keep backups for 30 days
# Telegram Bot Configuration (optional)
TELEGRAM_ENABLED="false" # Enable/disable Telegram notifications
TELEGRAM_BOT_TOKEN="" # Bot token from @BotFather
TELEGRAM_CHAT_IDS="" # Chat ID(s) for notifications
TELEGRAM_NOTIFY_UPDATE_START="true" # Notify when update starts
TELEGRAM_NOTIFY_UPDATE_SUCCESS="true" # Notify when update succeeds
TELEGRAM_NOTIFY_UPDATE_FAILURE="true" # Notify when update fails
TELEGRAM_NOTIFY_NO_UPDATE="false" # Notify when no update neededThe scripts support optional Telegram bot notifications to keep you informed about server updates and status changes. This feature allows you to receive real-time notifications on your phone or computer whenever the server is updated, encounters errors, or when maintenance is performed.
- Real-time Notifications: Get instant updates about server status
- Multiple Recipients: Send notifications to multiple users or groups
- Configurable Events: Choose which events trigger notifications
- Rich Formatting: Messages include emojis, timestamps, and server details
- Error Resilience: Script continues even if Telegram notifications fail
- Open Telegram and search for
@BotFather - Start a chat and send
/start - Send
/newbotto create a new bot - Follow the prompts to name your bot and choose a username
- Save the API token provided (format:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
For personal notifications:
- Search for
@userinfobotin Telegram - Start a chat and send any message
- Note the Chat ID from the response (e.g.,
123456789)
For group notifications:
- Add your bot to the group and make it an admin
- Send a message mentioning your bot:
@yourbotname hello - Visit
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates - Find the "chat" object and note the "id" field (negative for groups:
-987654321)
Edit config.sh and update the Telegram settings:
# Enable Telegram notifications
TELEGRAM_ENABLED="true"
# Your bot token from BotFather
TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
# Chat ID(s) where notifications will be sent
# For multiple recipients, separate with spaces: "123456789 -987654321"
TELEGRAM_CHAT_IDS="123456789"
# Choose which events to be notified about
TELEGRAM_NOTIFY_UPDATE_START="true" # When update process begins
TELEGRAM_NOTIFY_UPDATE_SUCCESS="true" # When update completes successfully
TELEGRAM_NOTIFY_UPDATE_FAILURE="true" # When update fails or errors occur
TELEGRAM_NOTIFY_NO_UPDATE="false" # When script runs but no update neededThe script sends formatted messages for different events:
- ๐ Update Start: Notifies when the update process begins, including current version
- โ Update Success: Confirms successful update with version change details
- โ Update Failure: Alerts about errors with troubleshooting information
- โน๏ธ No Update Needed: Confirms server is already up to date (optional)
โ
Minecraft Server Update Completed
๐
Time: 2025-07-24 14:30:15
๐ฅ๏ธ Server: minecraft-server
๐ฆ Updated: 1.21.44.01 โ 1.21.50.07
๐ฎ Server is ready to play!
- Enable notifications in
config.sh - Temporarily set
TELEGRAM_NOTIFY_NO_UPDATE="true" - Run the update script when no update is available
- You should receive a "no update needed" notification
Bot doesn't send messages:
- Verify
TELEGRAM_ENABLED="true" - Check bot token is correct and complete
- Ensure chat ID is accurate
- Confirm you've started a chat with the bot (
/start)
Messages not received:
- Check internet connectivity to
api.telegram.org - For groups, ensure bot has permission to send messages
- Verify bot is not blocked or restricted
Check logs for details:
tail -f /var/log/minecraft/minecraft-server.log- Keep your bot token secure and never share it publicly
- Set restrictive file permissions on
config.sh - Consider using environment variables for tokens in production
- The bot can only send to chats where it's been explicitly added
./start-server.sh# Graceful stop (with player warnings)
./stop-server.sh
# Force stop (immediate)
./stop-server.sh --force
# Check status only
./stop-server.sh --status# Using the manager script
./server-manager.sh connect
# Direct screen connection
screen -r minecraft-server
# As root user
sudo -u mcserver screen -r minecraft-server# Show comprehensive status
./server-manager.sh status
# Send command to server
./server-manager.sh command "say Hello players!"
# Quick start/stop/restart
./server-manager.sh start
./server-manager.sh stop
./server-manager.sh restartsudo ./update-server.sh# Check current vs latest version
./check-version.sh
# Show detailed server information
./check-version.sh --detailed
# Just compare versions (for scripting)
./check-version.sh --check-onlyThe update script now automatically detects the latest Minecraft Bedrock server version using multiple methods:
- Official Website Scraping: Downloads the Minecraft server page and extracts the latest version number
- Azure CDN Testing: Tests likely version patterns against the download server
- Fallback URL: Uses the configured URL from
config.shif automatic detection fails
The system validates all URLs before attempting downloads and provides clear error messages if detection fails.
The server runs in a screen session that can be accessed by both the mcserver user and root:
- Attach to console:
screen -r minecraft-server - Detach from console: Press
Ctrl+A, thenD - Kill session:
screen -S minecraft-server -X quit
The screen configuration allows root to attach to the mcserver user's screen session:
# As mcserver user
screen -r minecraft-server
# As root user
sudo -u mcserver screen -r minecraft-serverThe setup script creates a systemd service for automatic startup:
# Enable auto-start on boot
sudo systemctl enable minecraft-bedrock
# Start/stop via systemd
sudo systemctl start minecraft-bedrock
sudo systemctl stop minecraft-bedrock
# Check service status
sudo systemctl status minecraft-bedrockBackups are automatically created before each update:
- Location:
$BACKUP_DIR/minecraft-backup-YYYYMMDD-HHMMSS.tar.gz - Retention: Configurable in
config.sh(default: 30 days) - Contents: Complete server directory including worlds and configuration
# Force an update (which creates a backup)
sudo ./update-server.shAfter setup, your file structure will look like:
/home/mcserver/
โโโ minecraft-server/ # Server installation
โ โโโ bedrock_server # Server executable
โ โโโ server.properties # Server configuration
โ โโโ worlds/ # World data
โ โโโ ... # Other server files
โโโ backups/ # Backup storage
โ โโโ minecraft-backup-20231201-120000.tar.gz
โ โโโ ...
โโโ .screenrc # Screen configuration
/var/log/minecraft/ # Log files
โโโ minecraft-server.log
/path/to/scripts/ # Management scripts
โโโ config.sh
โโโ setup.sh
โโโ update-server.sh
โโโ start-server.sh
โโโ stop-server.sh
โโโ server-manager.sh
The setup script automatically configures UFW if available:
# Manual firewall setup (if UFW not used)
# Open port 19132/UDP for Minecraft Bedrock
sudo ufw allow 19132/udp
# For other firewalls, ensure port 19132/UDP is open-
Check if server executable exists and is executable:
ls -la /home/mcserver/minecraft-server/bedrock_server
-
Check logs:
tail -f /var/log/minecraft/minecraft-server.log
-
Verify user permissions:
sudo -u mcserver ls -la /home/mcserver/minecraft-server/
-
Check running screen sessions:
screen -list sudo -u mcserver screen -list
-
Kill stuck sessions:
screen -S minecraft-server -X quit
-
Fix ownership:
sudo chown -R mcserver:mcserver /home/mcserver/
-
Fix script permissions:
chmod +x *.sh
Edit server-manager.sh to add custom management commands.
Update the DOWNLOAD_URL in config.sh when new server versions are released.
Add a cron job to run backups periodically:
# Daily backup at 3 AM
0 3 * * * /path/to/scripts/update-server.sh > /dev/null 2>&1- The
mcserveruser has limited privileges - Screen sessions are configured for specific user access
- Backups are stored with appropriate permissions
- Log files are accessible but not world-writable
- Linux (64-bit recommended)
- bash
- wget
- unzip
- screen
- tar
- sudo
- systemd (optional)
- UFW (optional, for automatic firewall configuration)
- Internet connection (for downloads and Telegram notifications)
These scripts are provided as-is for managing Minecraft Bedrock servers. Use at your own risk and ensure you comply with Minecraft's terms of service.