Warning this article may contain opinions of the author that you and iTWire don't necessarily agree with. Don't let them get away with it - have your say with a comment!

No. 1 Story

HP job cuts loom for Australian employees

A number of Australian employees of Hewlett-Packard are facing the loss of their jobs as the global computer giant looks to slash its worldwide workforce by up to 30,000.

read more

The Road to Ubuntu - Backup Salvation

Opinion and Analysis

After the steep learning curve of developing my local backup script, creating one for FTP proved relatively easy.

Googling for FTP file backup scripts, I came across lftp and this script for SQL backups . I picked through for what I needed and cobbled together my own script, tarballing the files (with a timestamp filename) to reduce bandwidth needs. It looks like this;

# Source
sou="/windows/data/Documents and Settings/Adam/My Documents/Adam/Work/AAA In Progress"


# Destination folder on FTP server
des="backup"


# Number of copies to keep

count=96


### FTP SERVER Login info ###
FTPU="FTP-SERVER-USER-NAME"

FTPP="FTP-SERVER-PASSWORD"

FTPS="FTP-SERVER-IP-ADDRESS"


# delete oldest folder
lftp -u $FTPU,$FTPP -e "rm -rf /${des}/${count}; quit" $FTPS


#rename folders
while [ $count -gt 1 ]
   
do
      old=`expr $count - 1`
lftp -u $FTPU,$FTPP -e "mv /${des}/${old} /${des}/${count}; quit" $FTPS
     count=`expr $count - 1`
done


# tarball files in temp folder
now=$(date +%y-%m-%d_%H:%M)

tar -czf /tmp/backup_${now}.tar.gz "${sou}"/*


# make new dir on server, upload tarball, delete temp tarball (-E)
lftp -u $FTPU,$FTPP -e "mkdir /${des}/1; cd /${des}/1; mput -E /tmp/backup_${now}.tar.gz; quit" $FTPS


I tried to use "find ${des}/* -mtime +5 -exec rm {} \;" to delete old folders, but I couldn't get it to work with lftp.

All that was left now was to add the two scripts to crontab (the task scheduler) so they'll run automatically - every 10 minutes to the network drive and every 30 minutes to the FTP site;

10 * * * * /home/adam/Documents/scripts/backup-inprog-hyperspace.sh
30 * * * * /home/adam/Documents/scripts/backup-inprog-ftp.sh


So that's how I found backup salvation with Ubuntu. While it was a steep learning curve, most of my problems were due to the fact I was using a FAT32 network drive - a legacy from Windows World. Moving to any new OS is always going to present challenges, so I'm not holding a grudge against the penguin. Now we've got this backup problem sorted, hopefully we can get down to business.

PREVIOUS POST:
The Road to Ubuntu - Backup Hell

NEXT POST:
The Road to Ubuntu (or Leopard) - screw the OS, move your apps online with Google