On day one, create the initial full backup:
An incremental backup means you’re only backing up the files that have changed since the last backup. So instead of copying everything every time, which can be slow and take up a lot of space, you’re only saving the new or updated files.

What Is an Incremental Backup?

#!/bin/bash

SOURCE=”/home/ravi/documents/”
DEST=”/backup/documents/”
LOGFILE=”/var/log/rsync-backup.log”
DATE=$(date +”%Y-%m-%d %H:%M:%S”)

rsync -av –delete “$SOURCE” “$DEST” >> “$LOGFILE” 2>&1
echo “Backup completed at $DATE” >> “$LOGFILE”

The -v makes the output verbose (so we can log what’s happening), and --delete removes files from the backup if they no longer exist in the source. All output is written to a log file at /var/log/rsync-backup.log so we can check later if anything went wrong.

Why Use rsync?

sudo apt install rsync # Debian/Ubuntu
sudo yum install rsync # CentOS/RHEL

Our Backup Plan

rsync -a –link-dest=/backup/daily.0/ /home/ravi/documents/ /backup/daily.1/

sudo /usr/local/bin/rsync-backup.sh

Firt, run the backup script manually, which will trigger the backup process immediately and you’ll see a list of files being copied or skipped.

Step 1: Write the Backup Script

Backups might not feel exciting, but losing your data sure is. Once you set up incremental backups with rsync and cron, you can relax knowing your files are protected every single day.
Now make the script executable:
0 2 * * * /usr/local/bin/daily-rsync-rotate.sh

Bonus Tip: Back Up to a Remote Server

sending incremental file list
./
file1.txt
folder2/
folder2/file2.pdf

Backup completed at 2025-06-16 14:00:01

rsync is a powerful and reliable tool used for copying files and directories in Linux. What makes rsync special is its ability to sync only the differences between the source and destination.
In this guide, I’ll show you how to schedule incremental backups using rsync and cron. I’ll explain what incremental backups are, how rsync works under the hood, and how to automate the whole process with cron.
ls -lh /backup/documents/

cat /var/log/rsync-backup.log

sudo nano /usr/local/bin/rsync-backup.sh

rsync -av -e ssh /home/ravi/documents/ ravi@backup-server:/backup/ravi/

If rsync not installed, you can get it with:
Backups are like insurance; you don’t need them every day, but when disaster strikes, such as accidental file deletion, a disk failure, or a ransomware attack, it’s enough to ruin everything if you’re not prepared. That’s where smart backup planning comes in.
Here’s a basic rotation script for 7 days:
rsync -a /home/ravi/documents/ /backup/daily.0/

Always test your backups, make sure your scripts work, and don’t forget to check the logs from time to time. If you ever need to restore something, you’ll be glad you had this system in place.
crontab -l

Step 3: Test the Backup Setup

sudo chmod +x /usr/local/bin/rsync-backup.sh

Step 2: Schedule the Script with Cron

#!/bin/bash

rm -rf /backup/daily.7
mv /backup/daily.6 /backup/daily.7
mv /backup/daily.5 /backup/daily.6
mv /backup/daily.4 /backup/daily.5
mv /backup/daily.3 /backup/daily.4
mv /backup/daily.2 /backup/daily.3
mv /backup/daily.1 /backup/daily.2
mv /backup/daily.0 /backup/daily.1

rsync -a –delete –link-dest=/backup/daily.1 /home/ravi/documents/ /backup/daily.0/

crontab -e

If you want to go one step further and keep daily snapshots of your data (instead of just one backup folder), you can use the --link-dest option in rsync, which lets you make hard-linked backups basically creating new folders that look like full backups but only use space for files that changed.
It works locally (from one folder to another on the same system) or remotely (over SSH to another server). It also preserves file permissions, timestamps, symbolic links, and even supports deletion of removed files, which is fast, flexible, and already installed on most Linux distros.
First, let’s create a shell script to perform the backup.

Final Thoughts

0 2 * * * /usr/local/bin/rsync-backup.sh

Let’s say you have 10,000 files in a folder and only 20 of them changed today. An incremental backup will skip the 9,980 unchanged files and only back up the 20 that actually changed, which is efficient and perfect for daily backups.

Similar Posts