Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # /etc/init.d/mcremotebackup
- ### BEGIN INIT INFO
- # Provides: minecraft remote backups
- # Required-Start: $local_fs $remote_fs
- # Required-Stop: $local_fs $remote_fs
- # Should-Start: $network
- # Should-Stop: $network
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: ChoiceCraft Remote Backups
- # Description: Init script for minecraft/bukkit server remote backups.
- ### END INIT INFO
- # Created by s4ndal of Choicecraft
- #Service Name
- SERVICE="ChoiceCraft Remote Backup's"
- #Minecraft Username
- USERNAME="---"
- #Command
- RSYNC="rsync --times --bwlimit=1500 -r"
- PURGE="-mtime +15 -exec rm {} \;"
- #Paths
- ############
- #Local Paths
- ############
- #SkyBlock Local Path
- SBLOCAL="/home/---/remotebackups/sky"
- #HungerGames Local Path
- HGLOCAL="/home/---/remotebackups/hg"
- #SMP Local Path
- SMPLOCAL="/home/---/remotebackups/smp"
- #Island PVP Local
- IPLOCAL="/home/---/remotebackups/ip"
- #Factions Local
- FLOCAL="/home/---/remotebackups/f"
- ############
- #Remote Paths
- ############
- #Remote SkyBlock Path
- SBPATH="---@skyblock.choicecraft.net:/home/---/minecraft_backup/*"
- #Remote HungerGames Path
- HGPATH="---@hg1.choicecraft.net:/home/---/minecraft_backup/*"
- #Remote SMP Path
- SMPPATH="---@smp.choicecraft.net:/home/---/minecraft_backup/*"
- #Remote IslandPVP Path
- IPPATH="---@islandpvp.choicecraft.net:/home/---/minecraft_backup/*"
- #Remote Factions Path
- FPATH="---@factions.choicecraft.net:/home/---/minecraft_backup/*"
- #################################################
- ME=`whoami`
- as_user() {
- if [ "$ME" == "$USERNAME" ] ; then
- bash -c "$1"
- else
- su - $USERNAME -c "$1"
- fi
- }
- mc_remotebackup () {
- echo "$SERVICE have begun..."
- echo "Backing Up SKY..."
- as_user "$RSYNC $SBPATH $SBLOCAL"
- echo "SKY Back Up Complete."
- echo "Backing Up HungerGames..."
- as_user "$RSYNC $HGPATH $HGLOCAL"
- echo "HungerGames Back Up Complete."
- echo "Backing Up Island PVP..."
- as_user "$RSYNC $IPPATH $IPLOCAL"
- echo "IslandPVP Back Up Complete."
- echo "Backing Up Factions..."
- as_user "$RSYNC $FPATH $FLOCAL"
- echo "Factions Back Up Complete."
- echo "$SERVICE has completed!"
- echo "Purging Old Backups..."
- as_user "find $SBLOCAL $PURGE"
- as_user "find $HGLOCAL $PURGE"
- as_user "find $IPLOCAL $PURGE"
- as_user "find $FLOCAL $PURGE"
- echo "Purge Complete!"
- }
- case "$1" in
- backup)
- mc_remotebackup
- ;;
- *)
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement