Advertisement
ionstorm66

Minecraft World Backup

Feb 14th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #! /bin/bash
  2. # Minecraft Backup Script
  3. # Tim Hunter <ionstorm66@gmail.com>
  4. #
  5. # This Program is free from any and all copyrights.
  6. #
  7. # Requires one argument, which is the world folder.
  8. # I.E.: /opt/minecraft/world/ the arg is world
  9. #
  10. # Start config
  11. #
  12. Log = '/opt/minecraft/log/backup.log'
  13. MCDir = '/opt/minecraft/'
  14. BackupDir = '/backup/mc/'
  15. #
  16. # End of config
  17. #
  18. echo World: $1 Backup Started `date` >> $Log
  19. # Make the backupt folder if it dose not exist
  20. mkdir -p $BackupDir`date +%H`/$1/
  21. # rsync the last backup to the new backup. Makes the actual backup quicker.
  22. rsync -az --inplace $BackupDir`date -d "-1 hour" +%H`/$1/* $BackupDir`date +%H`/$1/
  23. #
  24. # Need some way to get the minecraft server to save all data, and stop saving
  25. #
  26. # Backup the world with rsync
  27. rsync -az --delete --inplace $MCDir$1/* $BackupDir`date +%H`/$1/; STATUS="$?"
  28. # See if the backup went though.
  29. # Very basic check, but it catches a few problems.
  30. if [ "$STATUS" = "0" ]
  31. then
  32. echo World: world_1 Backup Completed `date` >> $Log
  33. # notify of succsess
  34. else
  35. echo World: world_1 Backup Failed `date` >> $Log
  36. # notify of failure
  37. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement