Created
July 10, 2015 17:58
-
-
Save calebjones/fd53597b005b67655fa8 to your computer and use it in GitHub Desktop.
Change-aware Minecraft backup script
This file contains 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
#!/bin/bash | |
dateStr="`date +"%Y%m%d%H%M"`" | |
fileNamePrefix="name-of-backup" | |
tarFileName="${fileNamePrefix}-${dateStr}.tgz" | |
#echo "tarFileName: ${tarFileName}" | |
cd "/Users/USERNAME/Library/Application Support/minecraft" | |
lastBackupFile=`ls -rt | grep $fileNamePrefix | awk 'NR==0; END{print}'` | |
#echo "lastBackupFile: $lastBackupFile" | |
if [ -n "$lastBackupFile" ]; then | |
numNewerFiles=`find . -mnewer ${lastBackupFile} | egrep -e "(saves|options|launcher_profiles|screenshots)" | wc -l | awk {'print $1'}` | |
#echo "numNewerFiles: $numNewerFiles" | |
if [ "$numNewerFiles" -gt "0" ]; then | |
#echo "Found newer files since last backup... creating backup" | |
tar -zcvf $tarFileName saves screenshots launcher_profiles.json options.txt | |
scp $tarFileName user@HOST:/backup/path/ | |
fi | |
else | |
#echo "No last backup file found... creating backup" | |
tar -zcvf $tarFileName saves screenshots launcher_profiles.json options.txt | |
scp $tarFileName USER@HOST:/backup/path/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this run once every hour via cron.