Update README.md

This commit is contained in:
Nicolas Chan 2019-04-08 19:28:26 -07:00 committed by GitHub
parent 851c2a9718
commit 2467e1e2c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,10 @@
# Minecraft Backup # Minecraft Backup
Backup script for Linux servers running a Minecraft server in a GNU Screen Backup script for Linux servers running a Minecraft server in a GNU Screen
### Still in development, so use at your own risk! ### Disclaimer
Backups are essential to the integrity of your Minecraft world. You should automate regular backups and **check that your backups work**. While this script has been used in production for several years, it is up to you to make sure that your backups work and that you have a reliable backup policy.
Please refer to the LICENSE (MIT License) for the full legal disclaimer.
## Features ## Features
- Create backups of your world folder - Create backups of your world folder
@ -19,27 +22,48 @@ Backup script for Linux servers running a Minecraft server in a GNU Screen
## Installation ## Installation
1. Download the script: `$ wget https://raw.githubusercontent.com/nicolaschan/minecraft-backup/master/backup.sh` 1. Download the script: `$ wget https://raw.githubusercontent.com/nicolaschan/minecraft-backup/master/backup.sh`
2. Mark as executable: `$ chmod +x backup.sh` 2. Mark as executable: `$ chmod +x backup.sh`
3. Configure the variables (in the top of the script) 3. Use the command line options or configure default values at the top of `backup.sh`:
```bash Command line options:
SCREEN_NAME="PrivateSurvival" # Name of the GNU Screen your Minecraft server is running in ```text
SERVER_DIRECTORY="/home/server/MinecraftServers/PrivateSurvival" # Server directory, NOT the world; world is SERVER_DIRECTORY/world -a Compression algorithm (default: gzip)
BACKUP_DIRECTORY="/media/server/ExternalStorage/Backups/PrivateSurvivalBackups" # Directory to save backups in -c Enable chat messages
NUMBER_OF_BACKUPS_TO_KEEP=128 # -1 indicates unlimited -d Delete method: thin (default), sequential, none
DELETE_METHOD="thin" # Choices: thin, sequential, none; sequential: delete oldest; thin: keep last 24 hourly, last 30 daily, and monthly (use with 1 hr cron interval) -e Compression file extension, exclude leading "." (default: gz)
COMPRESSION_ALGORITHM="zstd" # Leave empty for no compression -f Output file name (default is the timestamp)
COMPRESSION_FILE_EXTENSION=".zst" # Leave empty for no compression; Precede with a . (for example: ".gz") -h Shows this help text
COMPRESSION_LEVEL=3 # Passed to the compression algorithm -i Input directory (path to world folder)
ENABLE_CHAT_MESSAGES=true # Tell players in Minecraft chat about backup status -l Compression level (default: 3)
PREFIX="Backup" # Shows in the chat message -m Maximum backups to keep, use -1 for unlimited (default: 128)
DEBUG=true # Enable debug messages -o Output directory
``` -p Prefix that shows in Minecraft chat (default: Backup)
4. Create a cron job to automatically backup -q Suppress warnings
-s Minecraft server screen name
-v Verbose mode
```
a. Edit the crontab: `$ crontab -e` Example usage of command line options:
```bash
b. Example for hourly backups: `00 * * * * /path/to/backup.sh` ./backup.sh -c -i /home/server/minecraft-server/world -o /mnt/external-storage/minecraft-backups -s minecraft
```
This will use show chat messages (`-c`) in the screen called "minecraft" and save a backup of `/home/server/minecraft-server/world` into `/mnt/external-storage/minecraft-backups` using the default thinning delete policy for old backups.
4. Create a cron job to automatically backup:
- Edit the crontab: `$ crontab -e`
- Example for hourly backups: `00 * * * * /path/to/backup.sh`
## Retrieving Backups
Always test your backups! Backups are in the `tar` format and compressed depending on the option you choose. To restore, first decompress if necessary and then extract using tar. You may be able to do this in one command if `tar` supports your compression option, as is the case with `gzip`:
Example:
```bash
mkdir restored-world
cd restored-world
tar -xzvf /path/to/backups/2019-04-09_02-15-01.tar.gz
```
Then you can move your restored world (`restored-world` in this case) to your Minecraft server folder and rename it (usually called `world`) so the Minecraft server uses it.
## Help ## Help
- Make sure the compression algorithm you specify is installed on your system. (zstd is not installed by default) - Make sure the compression algorithm you specify is installed on your system. (zstd is not installed by default)
- Make sure your compression algorithm is in the crontab's PATH - Make sure your compression algorithm is in the crontab's PATH