TwinDisk – a real-time backup program.

 

Executable for Windows: TwinDisk.exe

 

TwinDisk monitors the directories and files selected by user, with or without subdirectories, depending on configuration file. Certain events in the monitored directories lead to the “twin” events in the backup directory. The list of these events is shown below:

 

 

Twin directory (back up) can be kept on the local disk, on the shared disk located on another computer, or, with assistance of a command-line application such as SFTP, on a remote computer.

 

Configuration files

 

TwinDisk requires a configuration file. The configuration file must contain a special section for each directory that the user wants to back up. Here is a section of configuration file for one directory being backed up on a local or shared disk:

 

[directory]

local     = c:\Distr\order\ ;local directory to back up

twin      = x:\Distr\order\ ;backup directory

sublevels = 2               ;>=1 = recursive, 0 = not recursive

file      = *.doc           ;wildcards

file      = *.pdf

file      = *.xls

 

Here is a section of configuration file for backup via SFTP:

 

[directory]

local     = c:\Distr\projects\ ; local directory to back up

local_alt = c:/Distr/projects/ ; the same directory, but in unix notation (sftp requires that)

twin      = distr/projects/    ; backup directory (on remote computer)

sublevels = 2                  ;>=1 = recursive, 0 = not recursive

file      = *.doc              ; wildcards

file      = *.pdf

file      = *.xls

file      = credit_card_numbers.txt ; this will back up only files with this name

file      = *.htm

file      = *.html

cp        = chmod 744 "%t%f";put "%a%f" "%t%f" ; copy command

update    = put "%a%f" "%t%f"                  ; update command

rm        = rename "%t%f" "%t%f.deleted"       ; remove command (see notes)

mv        = rename "%t%o" "%t%f"               ; move command

mkdir     = mkdir "%t%f"                       ; make directory command

rmdir     = rmdir "%t%f"                       ; remove directory command

lsfile    = ls "%t%f"                          ; list file command

run       = c:\cygwin\bin\sftp user@remote_comp  ; system command to run sftp on your computer

prompt    = sftp>                              ; sftp prompt

 

Notes:

 

The configuration file can contain several such sections, one per directory that you want to back up. Use wildcards to select only the types of files or individual files that you actually want to back up from each directory. Of course you can use “file = *” and back everything up, but that creates unnecessary load on your processor and network.

 

If a section for a certain directory does not contain commands (cp, update, rm, mv, mkdir, rmdir, lsfile, run), it is regarded as a section for local or shared disk backup. If these commands are present, TwinDisk will try to use them to back up your files via a command-line application. The second example shows commands that will allow TwinDisk to use SFTP to back up your files on remote computer. If you would like to use some other application, its commands will have to be programmed into configuration file. Let me know if you need help with that.

 

Please note that in the example for SFTP backup, “remove” command will not actually remove the backup file or directory, but just rename it by adding “.deleted” to its name. This feature can be used to protect valuable files and directories from accidental deletion. If you delete such file or directory on your local disk, it will still be available in the backup. If you would like to actually delete backup files when the original files are deleted, replace that line with this:

rm = rm “%t%f”

 

Special symbols in configuration file commands:

 

Symbol

Description

Substituted with

%t

Twin directory

Twin

%a

Alternative name for local directory

local_alt

%f

File name

Actual file name to back up

%o

Old file name

File name before the file was renamed

 

Comments in configuration file are allowed only as separate line, starting with semicolon (;). In the examples above, the comments are illegal – please remove them before using these examples.

 

Although TwinDisk can theoretically use many command-line applications to copy files into backup, it has been tested only with local and shared disks, and with OpenSSH SFTP program available in Cygwin installation.

 

TwinDisk setup

 

  1. Create directory C:\Program Files\TwinDisk
  2. Put TwinDisk.exe into this directory
  3. Put your TwinDisk configuration file into this directory
  4. On your desktop, create the shortcut as shown below (cnf is your configuration file):

 

 

  1. TwinDisk can be started using this shortcut. You can also copy this shortcut into the Startup folder in your Program menu, and TwinDisk will start automatically when your computer starts.
  2. Once started, TwinDisk will check all directories for changes since its last run, and back up all changed files and files that cannot be found in backup. After this is done, it will go into monitoring mode and wait for any changes in monitored directories and files.
  3. To stop TwinDisk manually, just press Control+C in its console window. This may be necessary if you want to change your configuration file. If you will just shut your computer down, TwinDisk will shut itself down correctly.
  4. The twin directories shown in configuration file must be created by you on the backup computer, and should be initially empty. When started, TwinDisk will try to find these directories. If one or several of them are not available, TwinDisk will still back up the directories that have their twins available. It will also periodically check if the missing twins are there. As soon as one of the missing twin directories is found, TwinDisk will start copying files into it. This feature is useful if your backup server is shut down temporarily – you don’t have to restart TwinDisk, it will just wait until your backup server is working again. 

OpenSSH SFTP setup for use with TwinDisk

 

Since most of the Unix and Linux systems have SSH server from some version of OpenSSH, it makes sense to use OpenSSH SFTP to access such computers and use them as backup server. On Windows platform, the simplest way to install OpenSSH is to use Cygwin.

 

Instructions:

  1. Use this link to start Cygwin installation: http://www.cygwin.com/setup.exe
  2. In the setup program, be sure to select OpenSSH package for installation
  3. Configure SSH for passwordless connection using these instructions: http://www.phys.ufl.edu/~madorsky/ui/ssh_keys.htm
  4. Open windows console, and check that you can actually connect without a password to the backup computer:

c:\cygwin\bin\ssh user@remote_comp

where c:\cygwin\bin\ssh is path on your computer to SSH and SFTP applications, remote_comp is your backup computer, and user is your username on it.

  1. Try to run TwinDisk and see if it works.