Created
December 27, 2025 19:09
-
-
Save jmkim/b6bdd8f8ff73b010eda69897551bdba3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # m h dom mon dow command | |
| */5 * * * * /home/jmkim/papermc-backup.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| PAPER_DIR='/home/jmkim/papermc' | |
| WORLDS_DIR=('world' 'world_nether' 'world_the_end') | |
| BACKUP_DIR='/home/jmkim/papermc-backups' | |
| mkdir -p "$BACKUP_DIR" | |
| latest_backup="$(ls -1tr "$BACKUP_DIR" | tail -n 1)" | |
| if [[ -n "$latest_backup" ]]; then | |
| latest_md5sum="$(md5sum "$BACKUP_DIR/$latest_backup" | awk '{ print $1 }')" | |
| fi | |
| newtar_tmp="$(mktemp)" | |
| tar -Jcf "$newtar_tmp" -C "$PAPER_DIR" "${WORLDS_DIR[@]}" | |
| newtar_md5sum="$(md5sum "$newtar_tmp" | awk '{ print $1 }')" | |
| if [[ "$latest_md5sum" != "$newtar_md5sum" ]]; then | |
| mv "$newtar_tmp" "$BACKUP_DIR/$EPOCHREALTIME.tar.xz" | |
| else | |
| rm "$newtar_tmp" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment