Warning this article may contain opinions of the author that you and iTWire don't agree with.
Visit the last page to have your say in our forum.

No. 1 Story

Telstra adds one million mobile services, but Sensis plummets

Telstra has revealed the addition of almost one million new mobile services in the six months to December 2011, but Sensis revenues plummeted 24 percent in 12 months.

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




Loading comments ...



- sponsored feature -

The Death of Traditional BI: What’s Next?

How to Make Business Discovery Work for Your Business IP PABX BUYING GUIDE

Business Discovery takes its cues from consumer apps. Like Google, it encourages us- ers to hunt for and explore data without worrying about or even noticing the underly- ing technology. Their entire experience is working within an intuitive interface to get real-time, self-service results with only minimal training. ...more