How to Make rsync Update Files Transferred in Previous Executions

Abstract: Use the -u flag to prevent rsync from overwriting newer destination files during synchronization.

Created: 2026-08-17 by
To update files transferred in previous rsync executions, use the -u (update) flag. This option ensures that rsync only transfers files that are newer on the source than those on the destination, preventing the overwriting of newer local copies while keeping your remote data synchronized with the most recent changes from the source system efficiently and safely.

Understanding the Update Mechanism

When you run rsync without specific flags, it typically compares file modification times and sizes to determine what needs to be moved. If a file exists on both the source and destination, rsync checks if the source version is newer. However, in many workflows, you might have modified a file locally after the initial transfer, or the destination file might have been touched by another process, changing its timestamp without altering its content. In these scenarios, a standard sync might skip the update or overwrite your local work depending on the configuration. The -u flag, which stands for update, modifies this behavior specifically. It tells rsync to skip files that exist on the destination and have a newer modification time than the corresponding source file. This is crucial for incremental backups or when you want to ensure that the destination reflects the latest state of the source without destroying any work done on the destination side since the last sync. It essentially acts as a safety net against accidental data loss during synchronization tasks.

Basic Syntax for Updating Files

Implementing this feature requires adding the -u flag to your standard rsync command line. The basic structure remains similar to a regular copy operation, but the logic behind the transfer changes. You specify the source directory or file, followed by the destination path. For example, to synchronize a local directory to a remote server while updating only changed files, you would use:
rsync -avuz /path/to/source/ user@remote:/path/to/destination/
In this command, -a preserves attributes like permissions and timestamps, -v provides verbose output so you can see what is happening, -u enables the update mode, and -z compresses data during transfer to improve speed. The trailing slash on the source path is important; it tells rsync to copy the contents of the directory rather than the directory itself. Without it, the entire folder structure might be recreated under the destination name. If you are working with local directories only, the syntax is nearly identical. Simply replace the remote user and host with the target local path. This allows you to maintain two local copies where one is always an updated mirror of the other, provided no newer files were created on the target side independently.

Combining Update with Other Flags

While -u is powerful on its own, it is rarely used in isolation. It works best when combined with the archive mode (-a). The archive mode is a shorthand for several other flags, including -rlptgoD, which recursively copies directories, preserves links, permissions, ownership, and group settings. By using -au, you get the full benefits of an archive sync but with the added safety of the update filter. You should also consider using the --delete flag with caution. When --delete is active, rsync will remove files from the destination that no longer exist in the source. If you combine --delete with -u, you might encounter unexpected results. Specifically, if a file was deleted on the source but still exists on the destination because it was newer, -u will prevent its deletion. This can lead to a state where the destination contains "orphaned" files that are not present on the source. Therefore, carefully evaluate whether you need strict mirroring or just an update mechanism. For more complex scenarios involving exclusions, such as skipping certain subfolders, you can integrate exclusion patterns into your command. This complements the update logic by ensuring that irrelevant data is not even considered for comparison. See Excluding Subfolders when Copying Files between Directories using rsync in Arch Linux for details on managing these filters effectively.

Common Pitfalls and Verification

One common mistake is assuming that -u protects against all forms of data corruption. It only protects based on modification time. If a file is modified on the destination but its timestamp is manually set to an older value using touch, rsync will overwrite it. Always verify your command with the --dry-run or -n flag before executing critical transfers. This simulates the operation and prints out exactly which files would be transferred, allowing you to confirm that the update logic is behaving as expected. Another consideration is network latency. When syncing large datasets over slow connections, the update check happens for every single file. This can be time-consuming. Using the --checksum option (-c) forces rsync to compare checksums instead of just modification times. While this is slower, it is more accurate for detecting actual content changes, especially if timestamps have been altered or are unreliable due to filesystem quirks. However, for most daily updates, the time-based check provided by -u is sufficient and much faster. It is also worth noting how rsync handles partial transfers. If a transfer is interrupted, the destination file may be incomplete. A subsequent run with -u will see the incomplete file as having an older timestamp (if the interruption happened quickly) or a newer timestamp (if the file was partially written). To handle this robustly, consider using --partial to keep partially transferred files, ensuring that resumed transfers do not start from scratch. For further insights on managing file attributes during these operations, refer to How to Fix Rsync Not Setting File Permissions Correctly when Transferring Local to Remote. Ensuring permissions are correct helps maintain the integrity of the files once they are updated.

Frequently Asked Questions

Does rsync -u delete files missing from the source?

No, the -u flag only prevents overwriting newer files on the destination. It does not remove files that exist on the destination but not on the source. To achieve deletion of orphaned files, you must explicitly add the --delete flag to your command.

What happens if I modify a file on the destination after syncing?

If you modify a file on the destination, its modification time becomes newer than the source. On the next sync with -u, rsync will skip this file, preserving your local changes. This is useful for maintaining patches or configurations made directly on the server.

Can I use -u with ssh encryption?

Yes, -u works seamlessly with SSH encrypted transfers. You simply include the standard SSH connection details in your rsync command, such as specifying the user and host. The update logic operates on the file metadata regardless of the transport layer security.

Is there a risk of data loss when using -u?

There is minimal risk if used correctly. The primary risk is unintentionally preserving outdated files if their timestamps are manipulated. Always test with --dry-run first to ensure that the files you expect to be updated are indeed being processed by the tool.

How does -u differ from --ignore-existing?

--ignore-existing skips files that already exist on the destination, regardless of their age. -u only skips files that are newer on the destination. This means -u will still update existing files if the source is newer, whereas --ignore-existing never updates them once they are present.

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