So I run this minecraft server. And the users that play on it are always creating and developing new things constantly a.k.a. Michigan Tech University out of blocks!!
So there was a big need to backup the map directory quite a bit. Right now its only about 50MB’s or so but I know it will get bigger as more and more elements are added. So we decided that everyday backups should be sufficient.
The person who helps manage the minecraft server has his own box that he offered to host off-site backups on. Problem is, hes running windows with a measly ftp server:(
But that’s ok. I figured out how to backup the map, zip it up to the highest gzip compression, and get it backed up to his server. Here’s the script.
#!/bin/bash<br></br> #Take in the current date<br></br> CURDATE=$(date "+%H.%M.%S_%m-%d-%Y")<br></br> #cd into the latest directory.<br></br> cd /localbackupdir/latest<br></br> #take the current latest tarball and move it into the archive<br></br> mv *.tar.gz ../archive<br></br> #tar the bitch<br></br> tar -cf mc.backstor.$CURDATE.tar /home/minecraftmaster/hey0.minecraft.server/mcworld<br></br> #best compression anyone?<br></br> gzip -9 mc.backstor.$CURDATE.tar<br></br> #make it so minecraftmaster can work with the file on the local side if need be. (his server goes down a lot)<br></br> chmod 775 mc.backstor.$CURDATE.tar.gz<br></br> chown minecraftmaster mc.backstor.$CURDATE.tar.gz<br></br> ping -c 3 offsitebackupplace.net > /dev/null # try 3 pings and redirect output to /dev/null<br></br> #If the server responds, then continue with a ftp mount, cp the backup tarball, and umount<br></br> if [ $? -eq 0 ]; then<br></br> curlftpfs ftp://username:[email protected] /mnt/ftp<br></br> cp mc.backstor.$CURDATE.tar.gz /mnt/ftp<br></br> umount /mnt/ftp<br></br> fi
This should do what you want it to.
I probably should show you what the local backup directory looks like since early in the script, the tarball currently residing in ./latest is moved to ./archive to make room for the new tarball that’s about to be created
And on the ftp box, the minecraftmanager setup a directory as my / dir so I don’t need to worry about defining a path to store it on the remote side.
Basically just add a nice sexy cron job that runs this script whenever you want and you’re good to go!