How to Use Rsync for Incremental Backups on Your Dedicated Server

Rsync is a powerful tool used for performing backups and synchronizing files between different locations on your dedicated server. Unlike full backups, incremental backups only copy the changes made since the last backup, making them faster and more storage-efficient. This guide will walk you through the process of using Rsync for incremental backups on your dedicated server.

Step 1: Install Rsync (if not already installed)

Before you can use Rsync, ensure that it is installed on your server. To check if it's installed, run the following command in your terminal:

rsync --version

If Rsync is not installed, you can install it using the following commands, depending on your operating system:

  • On Ubuntu/Debian:
sudo apt update
sudo apt install rsync
  • On CentOS/RHEL:
sudo yum install rsync

Step 2: Choose a Backup Destination

Decide where you want to store your backups. Rsync allows you to back up data to a remote server, external drive, or even a network share.

  • Remote server: You’ll need SSH access to the remote server to store your backups.
  • Local backup: You can back up to another directory on your dedicated server.

Step 3: Understand Rsync Command Syntax

The basic syntax for Rsync is:

rsync [options] source destination
  • source: The directory or files you want to back up.
  • destination: The location where you want to store the backup.

For incremental backups, Rsync uses the --link-dest option to compare the current backup with the last backup and only copy the changes.

Step 4: Set Up the First Full Backup

Before using incremental backups, you need to perform the first full backup. This will be your baseline backup, which subsequent incremental backups will compare against.

For example, to back up your home directory to a remote server:

rsync -avz /home/ username@remote-server:/path/to/backup/
  • -a: Archive mode, which preserves permissions, timestamps, and symbolic links.
  • -v: Verbose output, so you can see the details of the backup.
  • -z: Compress the data during transfer to save bandwidth.

The first backup will be a complete copy of your data.

Step 5: Set Up Incremental Backups

Once the first full backup is complete, you can start performing incremental backups. Incremental backups only copy the changes made since the last backup, which reduces the time and storage required.

Use the --link-dest option to enable incremental backups. Here’s the basic syntax:

rsync -avz --link-dest=/path/to/previous/backup/ /path/to/source/ username@remote-server:/path/to/backup/
  • --link-dest=/path/to/previous/backup/: This option tells Rsync to compare the current backup with the previous one and only copy the differences.
  • /path/to/source/: The directory or files to back up.
  • username@remote-server:/path/to/backup/: The remote server and directory where the backup will be stored.

Step 6: Automate Incremental Backups Using Cron Jobs

To ensure that your backups run regularly, automate the process using cron jobs. A cron job is a scheduled task that can run scripts at specified times.

  • Open the crontab editor:
crontab -e
  • Add a line to schedule the incremental backup. For example, to run the backup every day at 2 AM:
0 2 * * * rsync -avz --link-dest=/path/to/previous/backup/ /path/to/source/ username@remote-server:/path/to/backup/

This cron job will run Rsync every day at 2 AM and perform an incremental backup of the specified directory.

Step 7: Monitor Your Backups

It’s important to monitor the backup process to ensure it is running smoothly. You can check your backup logs or set up email notifications for successful or failed backups.

For example, add a log file to your Rsync command to keep track of backup details:

rsync -avz --link-dest=/path/to/previous/backup/ /path/to/source/ username@remote-server:/path/to/backup/ >> /path/to/logfile.log 2>&1

Step 8: Restore Files from Incremental Backups

If you need to restore files from your incremental backups, Rsync can help with that too. To restore from a backup, simply run the Rsync command with the source set to your backup directory and the destination set to the location where you want to restore the data:

rsync -avz username@remote-server:/path/to/backup/ /path/to/restore/

Rsync will compare the backup with the destination and only transfer the files that need to be restored.

Step 9: Clean Up Old Backups (Optional)

To avoid using up too much disk space, you may want to delete old backups periodically. You can manually delete backups or set up a cron job to remove old backups after a certain period.

For example, to delete backups older than 30 days:

find /path/to/backup/ -type f -mtime +30 -exec rm {} \;

This command will find and remove all files in the backup directory that are older than 30 days.


By following these steps, you can easily set up and manage incremental backups using Rsync on your dedicated server. Incremental backups provide a fast and efficient way to ensure your data is securely backed up with minimal storage and bandwidth usage.

Was this answer helpful? 0 Users Found This Useful (0 Votes)