Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Ignore existing files or update only newer files with rsync

rajeshkumar created the topic: Ignore existing files or update only newer files with rsync

Ignore existing files or update only newer files with rsynca

Copying from local to remote

Note that all the examples shown in the post are for copying files from the local computer to a remote server/computer.

Default behavoir

The following command will recursively copy all files from the local filesystem from /var/www to the remote system at 10.1.1.1. Note the following:

Any files that do not exist on the remote system are copied over
Any that have been updated will be copied over, although note that rsync is extremely efficient in that only the changed parts of files are copied and if the file is exactly the same if it is not copied over at all
Any that have been deleted on the local system are deleted on the remote
1 rsync -raz –progress /var/www 10.1.1.1:/var

Ignore existing files

Use the –ignore-existing flag to prevent files from being copied over that already exist on the remote server. By adding this, we eliminate behaviors 2 and 3 in the list above and all that is done is this:

Any files that do not exist on the remote system are copied over
1 rsync –ignore-existing -raz –progress /var/www 10.1.1.1:/var

Update the remote only if a newer version is on the local filesystem

In the case I was talking about, we didn’t want to overwrite any files at the other end. However you may want to copy files over the have been updated more recently on the local filesystem which is done with the –update flag. The behavior is now like this:

Any files that do not exist on the remote system are copied over
Any files that exist on both local and remote that have a newer timestamp on the local server are copied over. (Conversely, any files that have an older timestamp are not copied over).
1 rsync –update -raz –progress /var/www 10.1.1.1:/var

Use –dry-run to see what will be copied

It can be a good idea to test what will be transferred before actually doing it to make sure you aren’t going to copy files that you don’t want to. The –dry-run flag helps you do this:
1 rsync –dry-run –update -raz –progress /var/www 10.1.1.1:/var

Combined with the –progress flag I have included in all the examples, –dry-run will output all the directories it looks at and then all the files that would be copied.

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

How to Configure HTTP/HTTPS Proxy on Linux and Windows (CLI, GUI, Registry, and APT)

Set up proxy access correctly on Windows and Linux for command-line tools, package managers, and system-level use. This guide covers quick commands, persistent configuration, and common troubleshooting steps.

Read More

Linux pmap Command Guide: Inspect Process Memory Maps with Practical Examples

Learn how to use the Linux pmap command to inspect per-process memory mappings, compare output modes, and troubleshoot high memory usage quickly. This updated guide includes workflow steps, command examples, and interpretation tips.

Read More

iostat Command Guide for Linux: 20 Practical Examples for CPU and Disk I/O Troubleshooting

Learn how to use iostat to monitor CPU and storage performance on Linux systems. This revised guide covers installation, 20 practical commands, metric interpretation, and a troubleshooting workflow.

Read More

xargs in Linux: Practical Commands, Safe Patterns, and Pipeline Workflows

This guide explains how to use xargs effectively in Linux/Unix shells, from basic stdin handling to safe file operations and parallel execution. You’ll learn practical command patterns, portability caveats, and safer alternatives.

Read More

Linux mount and umount Commands: Practical Examples, /etc/fstab, and Safe Unmounting

Learn how to mount and unmount filesystems reliably on Linux, from one-off commands to persistent /etc/fstab entries. This guide covers common filesystem types, command comparisons, and safe troubleshooting steps.

Read More

How to Use gsh to Run Linux Commands Across Multiple Servers

gsh (Group Shell) lets you execute one command across many Linux hosts from a single terminal. This guide explains host grouping with /etc/ghosts, core options, and practical command patterns.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x