14 Jun, 2008, The_Fury wrote in the 1st comment:
Votes: 0
There are many things in Linux that you can automate so that you just never have to think about them, backups of your full game code, pfiles and related server code come to mind here. Combine this with a free Gmail account and a daily cron job and you have a simple off site backup strategy.

It is assumed that mutt has been installed on your server or that you know how to use some other command line mailer to send your backup copies to a Gmail account.

The first thing you need to do is to make a backup shell script, making sure to use full paths for all commands /dir/subdir/moredir/pathtoserver There are a few things that i do in this script. I move any core files to a separate directory thats not inside the game directory as they dont need to be backed up, then i do a make clean to get rid of the executable and any *.o files. name this file backup.sh

#!/bin/sh

cd /path_to_homedir/game_dir/area
mv core* /path_to_homedir/core #move core files to another dir
cd /path_to_homedir/game_dir/src
make clean #make clean to get rid of o files and exe
cd /path_to_homedir
tar -cvzf server_backup_`date +%d-%m-%Y`'tar.gz server_dir #backup the server dir
cd /path_to_homedir/game_dir/src
make #recompile the exe file
cd /path_to_homedir


The next thing to do is to email the tar file to your gmail account, name the file email.sh

#!/bin/sh

mutt -s "Game Server Backup `date +%d-%m-%y`" -n -F /dev/null -a /path_to_homedir/server_backup_`date +%d-%m-%Y`.tar.gz yourname@gmail.com < /dev/null


now lets check to see if the server is running and if its not restart it. What this does is check to see if the startup script is running, if it is not then it will restart it. name this file restart.sh

#!/bin/sh

if ps xuw | grep -v grep | grep startup > /dev/null
then
echo "the server is running"
else
cd /path_to_homedir/game_dir/src
nohup ./startup&
echo "starting server again"
cd /path_to_homedir
fi


Ok so we have 3 scripts, lets put them all together using a couple of cron jobs and have them executed automatically. Make a file called cron.job
0 1 * * * /path_to_scripts/backup.sh
10 1 * * * /path_to_scripts/email.sh
*/2 * * * * /path_to_scripts/restart.sh


First run this command crontab -l to see if there are any cron jobs already and if there is, copy them and add them to cron.job file. Once thats done you can issue the command crontab cron.job to make active your cron jobs.

So what does the command in cron.job do, the first one will run backup.sh at 1am everyday the 2nd one will run email.sh at 1.10am everyday and the last one will run restart.sh every 2 minuites. I hope someone finds this stuff usefull.
15 Jun, 2008, Kelvin wrote in the 2nd comment:
Votes: 0
There's also GmailFS, which makes it as simple as copying the files to a mounted FUSE system. I've played with it in the past, and it's great at what it does (allow you to copy to-from a Gmail account's space).
15 Jun, 2008, The_Fury wrote in the 3rd comment:
Votes: 0
Thanks for that information. I took a look at the project and i have to agree that it would be perfect for the backup procedure above. The only limiting factor is being able to install the system and its libraries, which those without root access might have some trouble with. Most systems have mutt or mail installed on them which means that even those with very basic shell access can still have offsite backups.
0.0/3