home   |   contact
   
profile services projects tutorials
 
     
  home :: projects :: backup script       
 

Recent Projects

snapbomb
flexfwd
adrenalin
realworld
insite

General Programming

december project
threaded web server
recursive desent parser
kernel mod

Graphics Programming

introduction
subdivision
loop subdivision+
md2 file animator
key frame animator
collision detection
collision detection 2
cloth simulation
bsp tree/game
water simulation
radiosity

Shell Scripts

backup script
file transfer


   print this page
  email this page
> login

 backup shell script

Name: Backup Shell Script
Language: /bin/bash
API: OpenGL
Platform: Linux/Solaris


#!/bin/bash
#
# backup - simple backup script for all system users
#
# - look up anyone with a home dir
# - tar there dir into a backup location
# only updating the last tar file if
# necissary
# - This would get run by cron on whatever
# interval was deemed necissary
#
# Version 1.0 - Corey Auger
# corey@coreyauger.com
#

# set the path like a good little monkey
PATH=/bin:/usr/bin:/sbin:/usr/sbin

# set the location of file swe are using in the program
PASSWD=/etc/passwd # passwd file
BACKDIR=$HOME/backups # location of backup dir
USER=<username># ftp user name
FTPUSER=<username># ftp user name
FTPPASS=<pass> # ftp password
FTPDIR=ftp://ftp.cpsc.ucalgary.ca/www # ftp location

# chech if we can find the passwd file with read access
if ! [ -r $PASSWD ]; then
   echo "$PASSWD does not exist or acess is denied"
   exit 1
fi

# check if backup dir exists.. if not create it
if ! [ -d $BACKDIR ]; then
   mkdir $BACKDIR
fi
# for every user that has a home directory
for homedir in `cat $PASSWD | grep "$USER" | awk -F: '{ print $6 }'`
do
   if ! [ -f $BACKDIR/test.tar ]; then # see if there is a backup file there
      # no backup found so create a new one
      tar -cvvf $BACKDIR/test.tar $homedir/www 2> /dev/null 1> /dev/null
      continue
   fi
   # found a backup file so lets update it
   tar -uvf $BACKDIR/test.tar $homedir/bin 2> /dev/null 1> /dev/null
done

# check if we have lftp ( linux default ftp ... diferent syntax is needed then )
LFTP=$(which lftp | grep "lftp")
   if [ -n "$LFTP" ]; then
# use lftp since the system located it
   lftp -u $FTPUSER,$FTPPASS $FTPDIR 2>> $BACKDIR/ftperr 1> $BACKDIR/ftpnorm <    mput $BACKDIR/*
   quit
FTP_SCRIPT
else
# use normal ftp since we dont have lftp
   ftp -n $FTPDIR 2>> $BACKDIR/ftperr 1> $BACKDIR/ftpnorm <    user $USER $PASSWD
   mput $BACKDIR/*
   quit
FTP_SCRIPT
fi

# check the return code from ftp
if [ $? ]
   mail -u su-root -s "backup script ftp fail" su-root #change to mail function
fi


exit 0



FlexFWD

FlexFWD is a social fitness logging tool. Connect with friends and follow athletes. Log: crossfit, running, swimming, or cycling. With mobile applications for the iPhone and Android devices, FlexFWD also integrates with your Nike+ and Garmin devices. This is the Utimate site for tracking and comparing your fitness restults to your friends and family. Click here to visit the project.



december project

The december project is a distributed internet backup project that I have been working on. This project is a distubuted cloud style backup system with error correction codes built in.


one2one

One2one is an opensource project that I started at source forge. One2one is a database transformation tool. The tool allows for easy transformation of data from one source to another. Take general data descriptions and map them into complex table hierarchies of any major database vendors. Click here to goto sourceforge and download the project code.

 
  Copyright © corey auger 2004