Advertisement
Guest User

backup.sh

a guest
May 17th, 2012
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.79 KB | None | 0 0
  1. #!/bin/bash
  2. # Filename: backup.sh
  3. # Version: U0.1
  4. # Description: minecraft automated backup script
  5. # Usage: set source and backup variables
  6. #        set worlds to backup (worlds array)
  7. #        OPTIONAL: change the backup name formatting
  8. #        double click the file and select run (only do this once)
  9. #        WARNING: having spaces in foldernames will throw errors
  10. #        WARNING: by default folders in the backup directory are deleted after 2 days
  11. # source variable to be set to the lowest common directory of all minecraft world folders
  12.     source=/home/username/Desktop
  13. # backup variable to be set to the location where backups are to be stored (must make backup folder before executing)
  14.     backup=/home/username/Desktop/backup
  15. # set list of worlds between the parentheses below (location relative to source variable)
  16.     worlds=(/server1/world1 /server2/world2)
  17. while true
  18. do
  19. # to change when backups are delete modify the number after -mtime +
  20. # -mtime +[n days to keep old backups]
  21.     find $backup/* -mtime +2 -exec rm -f -r {} \;
  22. # if you do not want to delete old backups add # to the beginning of the line above
  23.     for world in ${worlds[@]}
  24.     do
  25. # all the name formatting is done on the line below. Type: date --help for help
  26.         backupName=${world##*/}_$(date +%F_%H.%M.%S)
  27.         if [ -d ${source}${world} ]; then
  28.             mkdir $backup/$backupName
  29.             cp -r ${source}${world} ${backup}/${backupName}/${world##*/}
  30.             if [ -d ${source}${world}_nether ]; then
  31.                 cp -r ${source}${world}_nether ${backup}/${backupName}/${world##*/}_nether; fi
  32.             if [ -d ${source}${world}_the_end ]; then
  33.                 cp -r ${source}${world}_the_end ${backup}/${backupName}/${world##*/}_the_end; fi
  34.         fi
  35.     done
  36.     sleep 3600
  37. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement