Transferring Periodic Backups of /mnt/tosh Using Rsync with Hard Link Handling

Abstract: Use rsync with --link-dest to create space-efficient incremental backups of /mnt/tosh by hard linking unchanged files.

Created: 2026-08-14 by

Use the -a (archive) flag combined with --link-dest to create efficient, space-saving incremental backups of directories like /mnt/tosh. This approach preserves hard links by pointing unchanged files to the previous backup snapshot, ensuring that your storage usage grows only with modified or new data while maintaining a complete file history.

The Challenge of Hard Links in Backups

When backing up a filesystem such as /mnt/tosh, you often encounter files that share the same inode. These are known as hard links. A standard copy operation duplicates every byte of data for each instance of the file, leading to massive redundancy and wasted disk space. If you have hundreds of music tracks or documents linked across multiple directories, a naive backup strategy will consume terabytes of unnecessary storage. The goal is to create a series of snapshots where identical files are not physically duplicated on the destination drive. Instead, they should point to the same physical data block. Rsync provides a mechanism to achieve this through the --link-dest option, which allows it to compare current files against a previous backup directory. If a file has not changed since the last backup, rsync creates a hard link to the existing file rather than copying it again. This technique is particularly vital for users managing large media libraries, such as the /mnt/tosh/vorbis directory mentioned in our context. By leveraging hard links, you can maintain daily or weekly backups without the storage costs scaling linearly with the size of your dataset. For more details on how rsync handles idempotency during these operations, you might find Is rsync idempotent? helpful for understanding why subsequent runs do not alter unchanged data unnecessarily.

Setting Up the Directory Structure

Before running the backup command, you need a logical structure on your destination drive to store the snapshots. It is best practice to organize these backups into dated subdirectories. This makes it easy to identify which backup corresponds to which day and allows the --link-dest flag to easily locate the most recent successful backup. Create a base directory for your backups, for example, /backup/mnt_tosh. Inside this, you will create timestamped folders. A common naming convention uses the date format YYYY-MM-DD. When you perform your first backup, there is no previous snapshot to link against, so all files must be copied. However, for every subsequent backup, you will specify the path to the most recently created folder. Ensure that your destination drive has sufficient space. While hard links save significant space, you still need room for new files and modifications. To verify if your destination drive can accommodate the upcoming transfer before committing resources, consider performing a dry run first. You can check available space and estimated transfer sizes by reviewing Determining If Enough Space is Available in Destination Drive for rsync Dry Run.

Constructing the Rsync Command

The core of this backup strategy relies on combining several flags to ensure data integrity, speed, and space efficiency. The primary command structure involves specifying the source directory, the destination directory, and the reference to the previous backup. For the initial backup, you do not use --link-dest. You simply archive the entire contents of /mnt/tosh to your first dated folder. As you prepare for subsequent backups, you construct the command to include the link destination. Here is the general syntax for an incremental backup:
rsync -a --link-dest=/path/to/previous/backup /mnt/tosh/ /path/to/current/backup/
The -a flag is crucial because it enables archive mode. This sets recursive mode, preserves symbolic links, permissions, ownership, timestamps, groups, and device files. Without this flag, you would lose critical metadata associated with your files in /mnt/tosh/vorbis and its subdirectories. It is important to note the trailing slashes. In rsync, a trailing slash on the source (/mnt/tosh/) means "copy the *contents* of the directory." Without the slash, it copies the directory itself. Ensure your paths are correct to avoid nesting issues where your backup ends up inside a folder named after the source directory. If you are dealing with sparse files—files that contain large blocks of zeros that are not actually stored on disk—you may want to optimize space further. While --link-dest handles hard links, sparse file handling can sometimes require additional attention. You can learn more about shrinking sparse files in Linux after copying them without the -S operator by reading How to Shrink Sparse Files in Linux After Copying Them Without the -S Operator.

Handling Permissions and Ownership

When backing up system directories or user-specific data, preserving ownership is essential. The -a flag includes the -o (owner) and -g (group) options. However, if you are running rsync as a regular user trying to back up files owned by root or another user, you may encounter permission denied errors. In such cases, you should run the command with sudo or ensure you have the necessary privileges. Alternatively, if you are backing up your own home directories, standard user permissions usually suffice. Always test the command with a small subset of files first to verify that permissions are being transferred correctly. Incorrect permissions can render your backup useless if you cannot read the restored files. Additionally, consider using the --delete flag with caution. This flag ensures that files deleted from the source are also removed from the destination. While this keeps the backup mirror clean, it can be dangerous if used incorrectly. For a robust backup strategy, many administrators prefer to keep deleted files in older snapshots and prune them manually or via a separate cleanup script, rather than deleting them immediately.

Scheduling and Automation

To make this backup process reliable, automate it using cron. Create a shell script that generates the current date, creates the new backup directory, and executes the rsync command. Schedule this script to run at a time when your system load is low. Monitor the logs of your cron jobs to ensure backups are completing successfully. Check the exit status of rsync; a zero indicates success, while non-zero values indicate errors. Regularly verify that your hard links are intact by comparing inode numbers between the current and previous backup directories. This verification step confirms that your space-saving measures are working as intended. By following these steps, you can maintain a comprehensive, space-efficient backup history of your /mnt/tosh filesystem. This method scales well even as your data grows, making it ideal for long-term archival needs.

Frequently Asked Questions

What happens if I change the --link-dest path to a non-existent directory?

If the directory specified in --link-dest does not exist, rsync will ignore the flag and perform a full copy of all files, just as if the flag were not present. This results in significantly higher storage usage and longer transfer times. Always verify that the previous backup directory exists before running the command.

Can I use --link-dest with remote destinations over SSH?

Yes, but both the source and destination servers must support the necessary filesystem features. Typically, you use rsync over SSH to connect to a remote server, and the --link-dest path must be accessible on the remote side. Ensure that the remote user has read access to the previous backup directory referenced in the link destination.

Does --link-dest work with symlinks?

No, --link-dest specifically handles hard links for regular files. Symlinks are handled separately by the -l flag within the archive mode. If a file is a symlink in the source, rsync will recreate the symlink in the destination, regardless of whether it is linked to a previous backup. It does not convert symlinks to hard links.

How do I delete old backups to free up space?

You can safely remove old backup directories using standard rm commands. Since unchanged files are hard-linked, deleting an old directory only removes the link count for those files. The actual data remains on disk as long as at least one other hard link (in a newer backup) points to it. Monitor inode usage to ensure you are reclaiming space effectively.

What is the difference between -a and -r in rsync?

The -r flag only enables recursive directory traversal, copying files and folders but ignoring metadata like permissions, ownership, and timestamps. The -a flag is shorthand for -rlptgoD, which includes recursion plus preservation of permissions, links, timestamps, group, owner, and devices. For backups, -a is almost always required to maintain file integrity.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More