Advertisement
jjacobson

Untitled

Jun 30th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #!/bin/bash
  2. # /etc/init.d/mcremotebackup
  3.  
  4. ### BEGIN INIT INFO
  5. # Provides: minecraft remote backups
  6. # Required-Start: $local_fs $remote_fs
  7. # Required-Stop: $local_fs $remote_fs
  8. # Should-Start: $network
  9. # Should-Stop: $network
  10. # Default-Start: 2 3 4 5
  11. # Default-Stop: 0 1 6
  12. # Short-Description: ChoiceCraft Remote Backups
  13. # Description: Init script for minecraft/bukkit server remote backups.
  14. ### END INIT INFO
  15.  
  16. # Created by s4ndal of Choicecraft
  17.  
  18. #Service Name
  19. SERVICE="ChoiceCraft Remote Backup's"
  20. #Minecraft Username
  21. USERNAME="---"
  22. #Command
  23. RSYNC="rsync --times --bwlimit=1500 -r"
  24. PURGE="-mtime +15 -exec rm {} \;"
  25.  
  26. #Paths
  27. ############
  28. #Local Paths
  29. ############
  30. #SkyBlock Local Path
  31. SBLOCAL="/home/---/remotebackups/sky"
  32. #HungerGames Local Path
  33. HGLOCAL="/home/---/remotebackups/hg"
  34. #SMP Local Path
  35. SMPLOCAL="/home/---/remotebackups/smp"
  36. #Island PVP Local
  37. IPLOCAL="/home/---/remotebackups/ip"
  38. #Factions Local
  39. FLOCAL="/home/---/remotebackups/f"
  40. ############
  41. #Remote Paths
  42. ############
  43. #Remote SkyBlock Path
  44. SBPATH="---@skyblock.choicecraft.net:/home/---/minecraft_backup/*"
  45. #Remote HungerGames Path
  46. HGPATH="---@hg1.choicecraft.net:/home/---/minecraft_backup/*"
  47. #Remote SMP Path
  48. SMPPATH="---@smp.choicecraft.net:/home/---/minecraft_backup/*"
  49. #Remote IslandPVP Path
  50. IPPATH="---@islandpvp.choicecraft.net:/home/---/minecraft_backup/*"
  51. #Remote Factions Path
  52. FPATH="---@factions.choicecraft.net:/home/---/minecraft_backup/*"
  53. #################################################
  54.  
  55. ME=`whoami`
  56. as_user() {
  57. if [ "$ME" == "$USERNAME" ] ; then
  58. bash -c "$1"
  59. else
  60. su - $USERNAME -c "$1"
  61. fi
  62. }
  63.  
  64. mc_remotebackup () {
  65. echo "$SERVICE have begun..."
  66. echo "Backing Up SKY..."
  67. as_user "$RSYNC $SBPATH $SBLOCAL"
  68. echo "SKY Back Up Complete."
  69. echo "Backing Up HungerGames..."
  70. as_user "$RSYNC $HGPATH $HGLOCAL"
  71. echo "HungerGames Back Up Complete."
  72. echo "Backing Up Island PVP..."
  73. as_user "$RSYNC $IPPATH $IPLOCAL"
  74. echo "IslandPVP Back Up Complete."
  75. echo "Backing Up Factions..."
  76. as_user "$RSYNC $FPATH $FLOCAL"
  77. echo "Factions Back Up Complete."
  78. echo "$SERVICE has completed!"
  79. echo "Purging Old Backups..."
  80. as_user "find $SBLOCAL $PURGE"
  81. as_user "find $HGLOCAL $PURGE"
  82. as_user "find $IPLOCAL $PURGE"
  83. as_user "find $FLOCAL $PURGE"
  84. echo "Purge Complete!"
  85. }
  86.  
  87. case "$1" in
  88. backup)
  89. mc_remotebackup
  90. ;;
  91. *)
  92. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement