Close Menu
IOupdate | IT News and SelfhostingIOupdate | IT News and Selfhosting
  • Home
  • News
  • Blog
  • Selfhosting
  • AI
  • Linux
  • Cyber Security
  • Gadgets
  • Gaming

Subscribe to Updates

Get the latest creative news from ioupdate about Tech trends, Gaming and Gadgets.

    What's Hot

    The AI Hype Index: AI-powered toys are coming

    June 27, 2025

    How to Schedule Incremental Backups Using rsync and cron

    June 27, 2025

    Hacker ‘IntelBroker’ charged in US for global data theft breaches

    June 27, 2025
    Facebook X (Twitter) Instagram
    Facebook Mastodon Bluesky Reddit
    IOupdate | IT News and SelfhostingIOupdate | IT News and Selfhosting
    • Home
    • News
    • Blog
    • Selfhosting
    • AI
    • Linux
    • Cyber Security
    • Gadgets
    • Gaming
    IOupdate | IT News and SelfhostingIOupdate | IT News and Selfhosting
    Home»Linux»How to Schedule Incremental Backups Using rsync and cron
    Linux

    How to Schedule Incremental Backups Using rsync and cron

    MarkBy MarkJune 27, 2025No Comments4 Mins Read
    How to Schedule Incremental Backups Using rsync and cron

    Introduction

    Are you ready to safeguard your valuable data? Backups might not seem thrilling, but they are crucial for preventing data loss due to accidental deletions, disk failures, or ransomware. This guide will dive into how to schedule incremental backups using rsync and cron in Linux. Learn how this powerful combination can efficiently preserve your files while saving space and time. Let’s get started!

    What Is an Incremental Backup?

    Incremental backups only save files that have changed since the last backup. Instead of duplicating every file, which can be sluggish and consume significant storage, only new or updated files are backed up. For instance, if you have 10,000 files and just 20 have changed today, an incremental backup will save only those 20 files, ensuring efficiency for regular backups.

    Why Use rsync for Backups?

    rsync is a powerful utility for copying files and directories in Linux. Its effectiveness lies in its ability to sync only the differences between the source and destination directories. Whether used locally or remotely, rsync preserves file permissions, timestamps, symbolic links, and supports deletion of non-existing files, making it an ideal solution for backups.

    How to Install rsync

    If rsync isn’t already installed on your system, you can easily add it:

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

    Creating Your Backup Plan

    Suppose your important files are under /home/ravi/documents/, and you want to back them up to /backup/documents/. Here’s how to create a backup using rsync and automate it with cron.

    Step 1: Write the Backup Script

    Create a simple shell script to manage the backup process:

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

    Paste the following script:

    #!/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"

    This script instructs rsync to sync files while keeping a detailed log.

    Step 2: Make the Script Executable

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

    Step 3: Schedule the Script with Cron

    Edit your cron jobs to run the backup script daily at 2:00 AM:

    crontab -e

    Add the following line:

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

    Verify the cron job with:

    crontab -l

    Step 4: Test Your Backup Setup

    Before allowing automated backups, manually run the script to ensure everything works:

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

    Check your backup directory and log file for any errors or issues.

    Creating Daily Snapshot Backups

    To keep daily snapshots of your data, use the --link-dest option in rsync. This method saves space by creating hard-linked backups:

    rsync -a /home/ravi/documents/ /backup/daily.0/

    For subsequent days, reference the previous day’s folder for incremental backups:

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

    Backup Rotation Script

    Use this rotation script to manage your backups:

    #!/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/

    Schedule it like the previous script!

    Bonus Tip: Back Up to a Remote Server

    To secure your data remotely, utilize rsync over SSH with configured SSH keys for passwordless login:

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

    Final Thoughts

    Backups may not seem exhilarating, but the pain of losing data is profound. Setting up incremental backups with rsync and cron helps you protect your files daily, allowing you peace of mind. Always test your setups, check logs, and ensure your backups are secure.

    FAQ

    Question 1: What are the benefits of incremental backups?
    Incremental backups reduce the amount of data stored and the time taken for backups by only saving changes made since the last backup.
    Question 2: Can I use rsync for backups on different systems?
    Yes, rsync can be used to back up files across different systems, both locally and remotely, making it a versatile tool for Linux users.
    Question 3: How can I check if my backup was successful?
    You can review the log file specified in your backup script, which will provide detailed information about the backup process and any errors encountered.

    Read the original article

    0 Like this
    Backups cron Incremental rsync schedule
    Share. Facebook LinkedIn Email Bluesky Reddit WhatsApp Threads Copy Link Twitter
    Previous ArticleHacker ‘IntelBroker’ charged in US for global data theft breaches
    Next Article The AI Hype Index: AI-powered toys are coming

    Related Posts

    Linux

    10 Bash Scripts to Automate Daily Linux SysAdmin Tasks

    June 27, 2025
    Linux

    Raspberry Pi 5 Tower Cases to Give it Desktop Gaming Rig Look

    June 25, 2025
    Linux

    KDE Frameworks 6.15 Improves Accessibility in Plasma’s System Settings App

    June 25, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    AI Developers Look Beyond Chain-of-Thought Prompting

    May 9, 202515 Views

    6 Reasons Not to Use US Internet Services Under Trump Anymore – An EU Perspective

    April 21, 202512 Views

    Andy’s Tech

    April 19, 20259 Views
    Stay In Touch
    • Facebook
    • Mastodon
    • Bluesky
    • Reddit

    Subscribe to Updates

    Get the latest creative news from ioupdate about Tech trends, Gaming and Gadgets.

      About Us

      Welcome to IOupdate — your trusted source for the latest in IT news and self-hosting insights. At IOupdate, we are a dedicated team of technology enthusiasts committed to delivering timely and relevant information in the ever-evolving world of information technology. Our passion lies in exploring the realms of self-hosting, open-source solutions, and the broader IT landscape.

      Most Popular

      AI Developers Look Beyond Chain-of-Thought Prompting

      May 9, 202515 Views

      6 Reasons Not to Use US Internet Services Under Trump Anymore – An EU Perspective

      April 21, 202512 Views

      Subscribe to Updates

        Facebook Mastodon Bluesky Reddit
        • About Us
        • Contact Us
        • Disclaimer
        • Privacy Policy
        • Terms and Conditions
        © 2025 ioupdate. All Right Reserved.

        Type above and press Enter to search. Press Esc to cancel.