Skip to content

Bash script to automate 7-day rotating backups of Minecraft server instances managed by MCSManager. Quiet, simple, and timezone-aware.

License

Notifications You must be signed in to change notification settings

r0n0c/MCSMan-bkup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MCSManager Minecraft Backup Script

This Bash script automates daily backups of Minecraft server instances managed by MCSManager. It safely backs up instance data and removes backups older than 7 days.

πŸ”§ Features

  • Reads instance IDs from a text file
  • Uses rsync for efficient incremental backups
  • Retains backups for 7 days
  • Outputs clean logs with local timezone timestamps

πŸ“ Folder Structure

/your-backup-folder/
β”œβ”€β”€ INST_LIST.txt # One instance ID per line
β”œβ”€β”€ 2024-05-20-abc123 # Daily backup folders
└── mcbk.sh # This backup script

πŸ“œ Setup Instructions

  1. Clone or copy this script to your backup folder.
  2. Set your desired values in the script:
    • BACKUP_BASE: Where you want backups stored
    • INSTANCE_LIST: Path to a file listing instance IDs
    • INSTANCE_BASE: Location of instance data (default used by MCSManager)
    • LOG_TZ: Your preferred timezone for logs
  3. Create an INST_LIST.txt file with one instance ID per line:
    abc123...
    def456...
    
  4. Set up a cron job (after MCSManager shuts down servers):
    0 0 * * * /path/to/mcbk.sh >> /path/to/mcbk.log 2>&1

πŸ•“ Timezone Support

You can customize the time zone used in logs by editing the LOG_TZ variable (e.g., "America/Chicago"). This does not affect the server time β€” only log formatting.

🧹 Retention

Backups older than 7 days are automatically deleted based on their folder name's date prefix (YYYY-MM-DD- format).

❗ Requirements

  • Bash
  • rsync
  • A working MCSManager environment (to stop and start your instances)
  • Proper permissions to read instance directories and write backups

βœ… Example Cron Entry

# Run every night at midnight
0 0 * * * /path/to/mcbk.sh >> /path/to/mcbk.log 2>&1

πŸ§ͺ Example Output

πŸš€ Minecraft Backup Started
πŸ•’ Start Time: 2024-05-20 00:00:01 CDT
πŸ“ Backup Base: /home/mc/backups
πŸ”„ Backing up instance: abc123...
βœ… Keeping recent backup: 2024-05-19-abc123
πŸ—‘οΈ  Deleting old backup: 2024-05-12-abc123
βœ… Minecraft Backup Completed
πŸ“¦ Instances Backed Up:
   - abc123...

About

Bash script to automate 7-day rotating backups of Minecraft server instances managed by MCSManager. Quiet, simple, and timezone-aware.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages