Hey Guys,
Have I got a treat for you!
*edit* I'm not actually sure what section this goes in, so mods, feel free to move it if this is the wrong place for it!
After reading "Johnleys fast and easy Server Setup Guide," I decided that I could make some modifications to his backup script to make it more powerful.
It also needs two lines in crontab, which you can modify however you want to make the backup happen at different intervals. (modified by typing "sudo crontab -e", editing it, and then saving)
Now, this script is designed to make a world backup every two hours, and a full modpack folder backup every twelve hours. I understand that it may not be necessary to have THAT many backups, but I find that it soothes the voice in the back of my head saying "What if hitting this with a wrench corrupts my world, and somehow deletes my whole modpack folder?" and "What if this guy griefs my base?". Up to you guys how often you want to run the script though. Note: if you want to make this happen at odd hours (like 1, 3, 5, etc.) you need to modify the if statements so that the hour % 3 == 0.
It's pretty simple, basically you add all of your directories here:
making sure that you end the paths exactly the way they end here (DOUBLE CHECK THE FORWARD SLASHES, you might accidentally delete everything if you don't) I use temporary directories, because zipping and transferring the files to my NAS takes some time, and world saving doesn't start up again until after it's done.
Now, you can set the name of your file here:
and here
(for the world and full backups respectively)
where it says "MonsterWORLDBKP-srv-$TIME.zip" and "MonsterFULLBKP-srv-$TIME.zip"
Also, you need to make sure that the script is accessing the right screen session by changing
"ftbM" to the name of your screen session in
(change it for every line of this) and you should be done! Save this file in the same directory as your "world" directory, make sure that the crontab links straight to this file, and you should be good!
If there's anything I've forgotten, or you have any problems, go ahead and comment! I promise I'll fix it...
Credits for the original script goes to Bråthen who posted it in Johnley's post on the forums.
~RabidBurn
Have I got a treat for you!
*edit* I'm not actually sure what section this goes in, so mods, feel free to move it if this is the wrong place for it!
After reading "Johnleys fast and easy Server Setup Guide," I decided that I could make some modifications to his backup script to make it more powerful.
Code:
#!/bin/bash
TIME=$(date +"%Y-%m-%d.%H")
HOUR=$(date +"%H")
DEST="/mnt/nasBackup/MonsterBackups"
SRCWORLD="/ftbLauncher/Monster/v1.1.1/world"
SRCFULL="/ftbLauncher/Monster/v1.1.1/"
TDESTWORLD="/ftbLauncher/Monster/v1.1.1/temp"
TDESTFULL="/ftbLauncher/Monster/temp"
screen -S ftbM -X stuff "say Starting backup. World not saving... $(printf '\r')"
screen -S ftbM -X stuff "save-off $(printf '\r')"
screen -S ftbM -X stuff "save-all $(printf '\r')"
#WORLD
if [ "$(($HOUR % 2))" = 0 ]; then
echo "$(($HOUR % 2))"
cp -r $SRCWORLD/* $TDESTWORLD
zip -r $DEST/WORLDBKPS/MonsterWORLDBKP-srv-$TIME.zip $TDESTWORLD/*
rm -r $TDESTWORLD/*
else
echo "Not a bi-hour."
fi
#END WORLD
#FULL
if [ "$(($HOUR % 12))" = 0 ]; then
cp -r $SRCFULL $TDESTFULL
zip -r $DEST/FULLBKPS/MonsterFULLBKP-srv-$TIME.zip $TDESTFULL*
rm -r $TDESTFULL/*
else
echo "Not a 12-hour."
fi
#END FULL
screen -S ftbM -X stuff "save-on $(printf '\r')"
screen -S ftbM -X stuff "say Backup complete. World saving again. $(printf '\r')"
It also needs two lines in crontab, which you can modify however you want to make the backup happen at different intervals. (modified by typing "sudo crontab -e", editing it, and then saving)
Code:
0 */2 * * * /ftbLauncher/Monster/v1.1.1/ftb-backup.sh
0 0 * * * /ftbLauncher/Monster/v1.1.1/ftb-backup.sh
Now, this script is designed to make a world backup every two hours, and a full modpack folder backup every twelve hours. I understand that it may not be necessary to have THAT many backups, but I find that it soothes the voice in the back of my head saying "What if hitting this with a wrench corrupts my world, and somehow deletes my whole modpack folder?" and "What if this guy griefs my base?". Up to you guys how often you want to run the script though. Note: if you want to make this happen at odd hours (like 1, 3, 5, etc.) you need to modify the if statements so that the hour % 3 == 0.
It's pretty simple, basically you add all of your directories here:
Code:
DEST="/mnt/nasBackup/MonsterBackups"
SRCWORLD="/ftbLauncher/Monster/v1.1.1/world"
SRCFULL="/ftbLauncher/Monster/v1.1.1/"
TDESTWORLD="/ftbLauncher/Monster/v1.1.1/temp"
TDESTFULL="/ftbLauncher/Monster/temp"
Now, you can set the name of your file here:
Code:
zip -r $DEST/WORLDBKPS/MonsterWORLDBKP-srv-$TIME.zip $TDESTWORLD/*
Code:
zip -r $DEST/FULLBKPS/MonsterFULLBKP-srv-$TIME.zip $TDESTFULL*
where it says "MonsterWORLDBKP-srv-$TIME.zip" and "MonsterFULLBKP-srv-$TIME.zip"
Also, you need to make sure that the script is accessing the right screen session by changing
"ftbM" to the name of your screen session in
Code:
screen -S ftbM -X stuff "blah blah blah"
If there's anything I've forgotten, or you have any problems, go ahead and comment! I promise I'll fix it...
Credits for the original script goes to Bråthen who posted it in Johnley's post on the forums.
~RabidBurn
Last edited: