Triad Hosting Incorporated Make Online Payments
Reseller Program 
Triad Hosting Incorporated Terms of Service  
    HOME         SERVICES     NETWORK SUPPORT ONLINE PAYMENTS CONTACT US
Triad Hosting Incorporated Triad Hosting Incorporated
Triad Hosting Incorporated
Affordable Business Class Web Hosting  

Remote Data Backup - Users Guide

Back to User's Guide

Rsync for LINUX (Red Hat)

INSTRUCTIONS TO SETUP KEYS (optional)

As the user you are going to be running rsync as, and on the machine you will be running rsync on, type:

ssh-keygen -t rsa
Follow the prompts and use the defaults for the filenames it gives you. Don't enter in a passphrase. You should then have two new files in ~/.ssh, id_rsa and id_rsa.pub.

Now, upload the newly created key to your account with this command:

scp -P SSH_PORT# ~/.ssh/id_rsa.pub USERANME@HOSTNAME:.ssh/authorized_keys

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.

Backing Up Files
At the command prompt type the following command:

rsync -avr -e 'ssh -p SSH_PORT# -i ~.ssh/id_rsa' files-to-backup 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
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

Automate with Crontab

Create a batch file as shown below by using a text editor:

#!/bin/bash

rsync -avr -e 'ssh -p SSH_PORT# -i ~.ssh/id_rsa' FILES-TO-BACKUP USERNAME @HOSTNAME:backups

Save the file as "backup.sh".
Change permissions of "backup.sh" to 0755.

Create a cron job to run the shell script at a specific time (7 pm, on every day). Example below.

0 19 * * * ./path-to-shell-script/backup.sh


Top of Page
Linux OS Apache Server PHP mySQL Database Powered by CentOS
Copyright © 2003-2009. Triad Hosting Inc. All rights reserved.
We endorse Open Source Software.