Sunday, January 30, 2011

ClearOS FTP backup script

Recently I had to find a way to do incremental backups of a ClearOS file server to a Seagate Black Armour NAS400. I was not involved in the hardware choice and this showed, because while the NAS is kinda useful... I find its lack of firmware intelligence frustrating. If anyone from Seagate ever reads this... please allow SSH and rsync by default please. The NAS seems to be more end user than server orientated.

So my limitations when coming up with a backup solution to the NAS was limited to just ye olde tar and good old ftp.

So using my Google-fu search skills I searched the Internet looking for reliable method of backing up the data in the flexishare directories. I found the best solution came with a bash shell script that automated the process for you.

For this solution you are going to need a particular type of ftp client. ncftp. By default ncftp does not come with ClearOS and for some reason its not in the ClearOS repositories either *hint hint*. (Yes, that was directed at any bored developer reading this guide.). Despite that its pretty easy to install if you know the basics of using terminal.

To install ncftp on ClearOS just these commands as root:

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

#yum install ncftp


Of course versions may change over time so just be sure to keep an eye out for updated code repositories. Especially if you are reading this 2 or 3 years from the date I wrote this.

Now that we have ncftp we can create a shell script and then run it. Drop down to terminal again and using nano (or whatever editor you feel most comfatable with) and paste the following code:

http://snipt.org/wlkG

The variables in it are pretty self explanitory. Just be sure to change the IP (192.168.0.2) of of the FTP server to whatever you have allocated to your FTP NAS. This script is a slightly modified version of the script that I generated using this wonderful little online wizard: http://bash.cyberciti.biz/backup/wizard-ftp-script.php

The modification came with inserting the "passive" command into the FTP upload part of the script. Just save and run the script and you should see a full backup made and then uploaded.

No comments:

Post a Comment