Technology news and Jobs arrow Seeking Nerdvana arrow The Road to Ubuntu - Backup Salvation
The Road to Ubuntu - Backup Salvation E-mail
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}

Powered By Joomla Tags

Please enable JavaScript in your browser to post your comment!



 
< Next story in category   Previous story in the category >
iTWire user statistics Visitors last 30 days
694,279
Subscribers 15,210
#1 independent technology news advertise here
  •   *  
  • Search
  • AdvSeach
  • Login
  • Events
  • FreeStuff

- Advertisement -

Featured Whitepapers

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.
Follow iTWire on Twitter

About iTWire

iTWire is all about technology news, information, jobs and community for the IT and telecommunications industry professional. Subscribe to our free ICT daily newsletter