Blog

Australian IT JOBS : Sydney IT jobs, UNIX jobs, Linux jobs, Java jobs, ASP jobs Linux.conf.au Linux.conf.au
Technology news and Jobs arrow Seeking Nerdvana arrow The Road to Ubuntu - Backup Salvation
The Road to Ubuntu - Backup Salvation PDF Print E-mail
Written by Adam Turner   
Monday, 05 November 2007
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


{moscomment}



Get stories like this delivered daily - FREE - subscribe now
When you subscribe get a 12 months license for LiveProject
Valued at $99 USD


LiveWire - Desktop alerts Download the FREE iTWire desktop alert widget LiveWire - Desktop alerts


Del.icio.us!


 
< Prev   Next >

The Digital Lounge Room

Seeking Nerdvana - Attaining oneness with tech Subscribe to the RSS
Seeking Nerdvana follows Adam Turner's quest to attain oneness with technology. Embedded in the digital lounge room, Adam offers a view from the couch of the front line where PC converges with AV.
Contact , Register , Advertise with iTWire , Links , Register , About iTWire , Feedback , Post your jobs , Events , iTWire site map , Start Blogging
Industry Releases , Submit your release now , Start submitting to iTWire , How to post video