Table of Contents

  1. Introduction
  2. Why Organizations Still Use rsync
  3. Understanding rsync and SSH
  4. Step-by-Step Guide to Remote Backups
  5. Real-World Use Case
  6. Summary

1. Introduction

Backups are essential for any system administrator. While many organizations invest in commercial backup solutions like Veritas NetBackup, Veeam, or Windows NT Backup, there's a simpler, open-source tool that's been trusted for years: rsync.

In this article, we'll explore how to use rsync over SSH to perform remote backups efficiently and securely.


2. Why Organizations Still Use rsync

Despite the availability of commercial tools, many organizations prefer rsync because:

  • Simplicity: Easy to set up and use.
  • Efficiency: Transfers only changed files, saving bandwidth and time.
  • Security: Works seamlessly over SSH for encrypted transfers.
  • Flexibility: Suitable for various backup scenarios, from small directories to entire systems.

3. Understanding rsync and SSH

rsync is a command-line utility that synchronizes files and directories between two locations. When combined with SSH, it allows secure data transfer over networks.

Basic Syntax:

rsync [options] [source] [user@remote_host:destination]

Common Options:

  • -a: Archive mode (preserves permissions, timestamps, symbolic links, etc.)
  • -v: Verbose output
  • -z: Compress data during transfer
  • -e ssh: Use SSH for data transfer

4. Step-by-Step Guide to Remote Backups

Step 1: Ensure rsync is Installed

On most Linux systems, rsync is pre-installed. To check:

rsync --version

If not installed, you can install it using your package manager:

  • For Red hat/CentOS:
sudo yum install rsync
  • For Debian/Ubuntu:
sudo apt-get install rsync

Step 2: Perform the Backup

To back up a directory from a remote server to your local machine:

rsync -avz -e ssh user@remote_host:/path/to/remote/directory /path/to/local/destination

Example:

rsync -avz -e ssh [email protected]:/var/www/html /home/user/backup/html

This command will:

  • Connect to remote_host as user.
  • Synchronize the /var/www/html directory from the remote server to /home/user/backup/html on the local machine.
  • Preserve file permissions, timestamps, and compress data during transfer.

5. Real-World Use Case

Imagine you're managing a web server hosted on AWS, and you want to back up the website files to your local machine daily.

Step 1: Set Up SSH Access

Ensure you can SSH into the remote server:

Step 2: Create a Backup Script

Create a script named backup.sh:

#!/bin/bash
rsync -avz -e ssh [email protected]:/var/www/html /home/user/backup/html

Make the script executable:

chmod +x backup.sh

Step 3: Schedule the Backup

Use cron to schedule the backup daily at 2 AM:

0 2 * * * /path/to/backup.sh

This setup ensures that your website files are backed up daily without manual intervention.


6. Summary

While commercial backup solutions offer advanced features, rsync remains a reliable and efficient tool for many organizations. Its simplicity, combined with the security of SSH, makes it an excellent choice for remote backups.

By following the steps outlined above, you can set up automated, secure backups for your systems, ensuring data integrity and peace of mind.

Connect with me on LinkedIn: https://linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=sheikhhassaanbinnadeem