Nav links

Sunday, 6 April 2014

Replacing Cobian Backup


I've been using Cobian Backup for years to make automated monthly local backups of data on remote servers. However, I use very few of its features, and with my switch to more secure data transfer methods it has become time-consuming to configure to my needs. So, after a recent refresh of Windows 8.1 I took the opportunity to develop a new, simpler and faster backup strategy.

To retrieve data via SFTP I now use the command-line utility psftp, and to retrieve from a different server using FTP (where the more secure SFTP was not available) I use Windows built-in FTP client. The whole lot is scripted with a simple Windows batch file, a simplified extract of which is show below.

REM Prepare backup on SFTP server GOLDFISH 
plink.exe -pw PASSWORD USERNAME@GOLDFISH tar -cvzf /remote/path/to/backup.tar.gz /path/to/data/*
 
REM Retrieve backup from GOLDFISH, and delete backup 
psftp USERNAME@SERVER -batch -pw PASSWORD -b get-goldfish.scr

REM Retrieve data from FTP server PIGGY
mkdir c:\path\to\backups\raw\piggy
ftp -n -s:get-piggy.scr

My first step was to connect via SSH to the GOLDFISH server and archive some files directly on there. Doing this meant my download script would only have to download one compressed file, rather than hundreds of little files. For this I used Plink, a companion tool to psftp.

I then used psftp to run a script file, get-goldfish.scr, to do the download via sftp:

lcd c:/local/path/to/backups/remote/
get /remote/path/to/BACKUP.tar.gz 
del /remote/path/to/BACKUP.tar.gz

Finally, I got the Windows ftp client to run a script file, get-piggy.scr, to do its download:

open SERVER
user USERNAME 
PASSWORD
lcd c:\local\path\to\backups
cd REMOTE_FOLDER
get FILE1.NAME
get FILE2.NAME
bye

This is a very UNIX-y way of doing things, and I find it works very well. GUI applications for simple tasks such as these are overkill. Easily configurable command-line scripts offer simplicity and reliability for power users such as you and me.