Remote Data Backup - Users Guide

Rsync For Windows

cwRsync is a distribution of the rsync utility that is optimized for quick and easy installation in Microsoft Windows. Supported platforms: Client - Windows 9x/NT/2000/XP/2003/2007.

 

You can download cwRsync http://www.itefix.no/cwrsync/

 

Once you have downloaded this installation file, run it. You should select the defaults the installer gives you, including the default installation path of:
C:\Program Files\cwRsync
We STRONGLY recommend installing the program in the default location.

 

Setting up your public/private keypair (optional)
You need to create, and upload, an SSH public key so that your rsync backups can occur without your being prompted for a password.

 

It is VERY IMPORTANT that the user who creates the key is the SAME user as the one who runs the automated backup. The easiest way to ensure this is to log in as the local "administrator" to perform the following steps:

 

Click the start button, and choose "run". In the run dialog box, type "cmd" and hit enter. The command prompt window (DOS prompt) will open.

 

In this command prompt, type:
cd c:\program files\cwrsync\bin

 

and hit enter. Then type:
ssh-keygen -t rsa -N ''
and hit enter.

 

(Note that the line ends with a space then TWO single quote characters, one after another)

 

You will be asked to "enter file in which to save the key" - just hit enter to accept the default that is given.

 

Now, upload the newly created key to your Triad Hosting Remote Backup filesystem with this command:
rsync -ave 'ssh -p SSH_PORT#' "/cygdrive/c/documents and settings/administrator/.ssh/id_rsa.pub" USERNAME@HOSTNAME:.ssh/authorized_keys
When you run this rsync command, you will be asked to confirm the first connection - enter "yes", and when prompted for your password, enter the password that was given to you in your welcome email.

 

Note: The directory ".ssh" must have permission set to 0700, and the file "authorized_keys" must have permissions set to "0600" bofore the key to work. To check or change permissions, login with WinSCP, right click the file or directory, choose 'Propeties', and under 'Permissions' change them as needed.

 

Your RSA public key is now uploaded to your Triad Hosting Remote Backup filesystem, and any further logins over ssh that this Windows user (in this case, administrator) performs will not require a password.

 

Choosing What To Back Up
Now you need to decide what to back up. Generally, installed programs, like the ones installed in C:\Program Files are not important to back up, nor is your primary C:\Windows folder. Generally you are only interested in backing up your data, often times limited to c:\My Documents, or c:\Documents and Settings. In this example we are choosing to back up the following directory:
C:\Documents and Settings\administrator

 

Create the Backup Script
Open the rsync script by going to the start menu, choosing Programs, then choosing cwRsync, then choosing "1. Batch Example". When you select this, the script will open in a text editor.

 

Save this file to a location you can remember. Name this file "backup1.bat" You will later setup a desktop icon so you can manually run the backup.

 

Leave the file exactly as it is - the settings in place are very important. You are simply going to add one or more rsync commands to the end of it, one for each folder or file you want to back up.

 

In this example we are adding a single line to the end of the file:
rsync -avr --chmod u+rwx -e "ssh -p SSH_PORT# -i c:\docume~1\administrator\.ssh\id_rsa" "/cygdrive/c/Documents and Settings/administrator" USERNAME@HOSTNAME:backups
The "-avr" of the command stands for:
  • a: archive, preserves all attributes like ownership, timestamps, etc
  • v: verbose output
  • r: recursive, recurse into directories
You can see how the source directory: C:\Documents and Settings\administrator is entered as /cygdrive/c/Documents and Settings/administrator this transformation is required for all Windows source folders.

 

You can add as many rsync lines to the end of this script as you like - one for each folder you wish to back up. Once the rsync lines have been added to the script, you should save the file and exit the editor.

 

Extra Rsync Command Line Options
Add any of these commands after the '-avr' command. You may include as many of these commands as you want.
  • --delete
    This will delete files remotely that no longer exist locally.

     

  • --exclude='*.jpg'
    This will exclude all files having the jpg extension

     

  • --include='*.jpg'
    This will include files having the jpg extension

     

  • --progress
    Shows you the progress of all the files that are being synced

     

  • --dry-run
    Shows what would have been transferred, but does not transfer anything

 

Manually Run The Backup
To create a desk-top icon follow these steps:
  • Right click the desk-top
  • Choose New then Shortcut
  • Browse to this backup script (backup1.bat)
  • Name the Icon
  • Finish

 

Now click this Icon on the desktop to start the backup script. You should NOT be prompted for a password. If you are then you do not have the path to the Key right.

 

Scheduling the Backup

All that is left now is to schedule the backup, which is done through Task Scheduler, which is included in Windows.

 

Open Task Scheduler by choosing: Start Menu, Programs, Accessories, System Tools, Scheduled Tasks.

 

The Scheduled Tasks explorer will open. Double click the item named "Add Scheduled Task".

 

In the first Window, simply click "Next".

 

In the second Window, you are asked to "click the program you want windows to run". Do not choose a program from the list. Instead, click the "browse" button.

 

Choose the program c:\program files\cwrsync\cwrsync.cmd

 

In the third window, you are asked to "type a name for this task" - you can name it whatever you like. Perhaps "Remote Backup". You are also asked, in this third window, how often to perform the task. In this example we will choose to perform the backup weekly.

 

In the fourth window, you are asked to choose a start time. We suggest sometime between 10pm and 6am. You should not perform these backups during the business day, as the network traffic they consume could affect your work.

 

In the fifth window, you are asked to "Enter the name and password of a user" - this is the Windows login that the backup will run under, and it is important that you choose the same Windows login that you used to create your RSA key, above. The username is entered in the form computername\username ... for instance: server01\administrator The password should be entered as well.

 

In the sixth and final window, click "finish".

 

Testing your Backup

It is extremely important that you test your backup. You are testing not only that the backup works properly and transfers the files you think it will, but also that it will properly log into your Triad Hosting Remote Backup filesystem without prompting you for a password.

The first test, making sure the automated backup is not prompted for a password, is performed simply by running the backup yourself.

From the start menu, choose Run, and type in the location of your backup script:

c:\progra~1\cwrsync\cwrsync.cmd
You should see the backup run in the command prompt that appears, and it should complete without asking you for a password. After you have completed a successful backup, and periodically as time goes on, you should then log into your Triad Hosting Remote Backup account and browse your filesystem.

 

Additional Notes
When testing your backup, be sure that Administrator is NOT logged onto the system twice - otherwise the DOS window that appears when your backup runs automatically from the Windows scheduler may appear in the other session (perhaps a remote access login). Having the administrator account logged into the system more than once can cause you not to see error messages that will help you diagnose the batch file if it is not running properly from the Windows scheduler.

 

The sample rsync command above has a setting: --chmod u+rwx that ensures that all files you upload to Triad Hosting Remote Backup, in addition to whatever other permissions they have, are given read/write/execute permission for the files owner. This setting is highly recommended and should only be altered if you know exactly what you are doing. It should be noted, however, that this may result in files on the remote side with more permissive permissions than the source files.
Vulnerability Scanner