A Simple Backup Script

Login to reply  Page: « < 1 of 1 > »
28 May 2010 - 11:232641
A Simple Backup Script
I placed this script in the parent directory of the game. So, if my game is in /home/axanon/tbamud, I put the script in /home/axanon. Modify the variables to suit your needs.

#!/bin/bash
# Simple backup script for CircleMUD/TBA

# Change these to your setup:
DEST=/home/axanon/backup
SRC=tbamud

# This names the backup file after the current date and time. 
# You probably shouldn't modify it.
FILENAME=`date +"%m-%d-%Y_%H.%M.%S"`

# Check to see we're looking in the right place for the game.
if [ ! -d $SRC ]
        then
        echo "ERROR: $SRC does not exist! Setup the script properly"
        exit 1
fi

# Check the destination folder, see if it exists, if not make it.
if [ ! -d $DEST ]
  then
  echo "Creating destination directory $DEST"
  mkdir $DEST
fi

# This does not save binaries (to save space). 
# If restoring, you will need to recompile if you restore.
tar --no-recursion -vcf $DEST/$FILENAME.tar $SRC/*
tar -vuf $DEST/$FILENAME.tar $SRC/cnf/*
tar -vuf $DEST/$FILENAME.tar $SRC/doc/*
tar -vuf $DEST/$FILENAME.tar $SRC/lib/*
tar -vuf $DEST/$FILENAME.tar $SRC/lib/etc/*.*
tar -vuf $DEST/$FILENAME.tar $SRC/src/*
echo "Removing .o files..."
tar --delete -f $DEST/$FILENAME.tar $SRC/src/*.o
echo "Done."
# Make the files even smaller
/bin/gzip -v $DEST/$FILENAME.tar
echo "Backup complete."
exit 0

The cron job...
Run:
crontab -e
and add:
0 3 * * * cd "/home/axanon/"; ./backup.sh &
*This runs the job at 3am every morning. Modify to suit your needs though.



Last edited by Axanon (28 May 2010 - 11:27)
Login to reply  Page: « < 1 of 1 > »