Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Filename: backup.sh
- # Version: U0.1
- # Description: minecraft automated backup script
- # Usage: set source and backup variables
- # set worlds to backup (worlds array)
- # OPTIONAL: change the backup name formatting
- # double click the file and select run (only do this once)
- # WARNING: having spaces in foldernames will throw errors
- # WARNING: by default folders in the backup directory are deleted after 2 days
- # source variable to be set to the lowest common directory of all minecraft world folders
- source=/home/username/Desktop
- # backup variable to be set to the location where backups are to be stored (must make backup folder before executing)
- backup=/home/username/Desktop/backup
- # set list of worlds between the parentheses below (location relative to source variable)
- worlds=(/server1/world1 /server2/world2)
- while true
- do
- # to change when backups are delete modify the number after -mtime +
- # -mtime +[n days to keep old backups]
- find $backup/* -mtime +2 -exec rm -f -r {} \;
- # if you do not want to delete old backups add # to the beginning of the line above
- for world in ${worlds[@]}
- do
- # all the name formatting is done on the line below. Type: date --help for help
- backupName=${world##*/}_$(date +%F_%H.%M.%S)
- if [ -d ${source}${world} ]; then
- mkdir $backup/$backupName
- cp -r ${source}${world} ${backup}/${backupName}/${world##*/}
- if [ -d ${source}${world}_nether ]; then
- cp -r ${source}${world}_nether ${backup}/${backupName}/${world##*/}_nether; fi
- if [ -d ${source}${world}_the_end ]; then
- cp -r ${source}${world}_the_end ${backup}/${backupName}/${world##*/}_the_end; fi
- fi
- done
- sleep 3600
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement