Skip to content

Instantly share code, notes, and snippets.

@x1024
Last active December 23, 2015 02:58
Show Gist options
  • Save x1024/6569982 to your computer and use it in GitHub Desktop.
Save x1024/6569982 to your computer and use it in GitHub Desktop.
Minecraft rolling backup script.
#!/bin/bash
echo "Backup perfomed at: `date +'%Y/%m/%d %H:%M'`"
echo "Backup perfomed at: `date +'%Y/%m/%d %H:%M'`" >> backups.log
# Make a backup
cp -r ~/unleashed/world ~/unleashed/backups/world_`date +%Y_%m_%d_%H_%M`
pushd ~/unleashed/backups
# Keep only the latest 50 backups
# First show what we're deleting
ls -t | sed -e '1,50d' | xargs -d '\n' echo
# Then delete it
ls -t | sed -e '1,50d' | xargs -d '\n' rm -r
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment