How to Use Rsync to Sync New or Changed/Modified Files in Linux
As a system administrator or Linux power user, you may have probably come across or even on several occasions, used the versatile Linux Rsync tool, which enables users to expeditiously copy or synchronize files locally and remotely. It is as well a great tool popularly used for backup operations and mirroring.
Some of its eminent features and advantages include; it is exceptionally versatile in that, it can copy locally, to/from a remote shell or remote rsync, it is also remarkably flexible, allowing users to specify any number of files to copy.
Suggested Read: 10 Practical Examples of Rsync Command in Linux
Furthermore, it permits copying of links, devices, file or directory owner, groups and the permissions. It also supports usage without root privileges coupled with many more.
One imperative differential of rsync in comparison to other file-coying commands in Linux is its use of the remote-update protocol, to transfer only the difference between files or directory content.
Therefore, in this article, we shall examine how rsync can help us only sync new or changed files or directory content while making backups and beyond in Linux.
To start with, you need remember that the conventional and simplest form of using rsync is as follows:
# rsync options source destination
That said, let us dive into some examples to uncover how the concept above actually works.
Syncing Files Locally Using Rsync
Using the command below, am able to copy files from my Documents directory to /tmp/documentsdirectory locally:
$ rsync -av Documents/* /tmp/documents
In the command above, the option:
-a
– means archive mode-v
– means verbose, showing details of ongoing operations

Sync Files Locally
By default, rsync only copies new or changed files from a source to destination, when I add a new file into myDocuments directory, this is what happens after running the same command second time:
$ rsync -av Documents/* /tmp/documents

Sync New Updated Files
As you can observe and notice from the output of the command, only the new file is copied to the destination directory.
Suggested Read: How to Sync Two Apache Web Servers/Websites Using Rsync
The --update
or -u
option allows rsync to skip files that are still new in the destination directory, and one important option, --dry-run
or -n
enables us to execute a test operation without making any changes. It shows us what files are to be copied.
$ rsync -aunv Documents/* /tmp/documents

Dry Run Rsync Before Syncing Files
After executing a test run, we can then do away with the -n
and perform a real operation:
$ rsync -auv Documents/* /tmp/documents

Sync Updated Files
Syncing Files From Local to Remote Linux
In the example below, I am copying files from my local machine to a remote sever with the IP address –10.42.1.5. So as to only sync new files on the local machine, that do not exist on the remote machine, we can include the --ignore-existing
option:
$ rsync -av --ignore-existing Documents/* aaronkilik@10.42.1.5:~/all/

Sync Files Local to Remote Linux
Subsequently, to sync only updated or modified files on the remote machine that have changed on the local machine, we can perform a dry run before copying files as below:
$ rsync -av --dry-run --update Documents/* aaronkilik@10.42.1.5:~/all/
$ rsync -av --update Documents/* aaronkilik@10.42.1.5:~/all/

Check Sync Only Updated Files
To update existing files and prevent creation of new files in the destination, we utilize the --existing
option.
You can run through the rsync man
page to discover additionally useful options for advanced usage, as I had mentioned earlier on, rsync is a very powerful and versatile Linux tool and many System Administrator and Linux power users know just how advantageous it is.
Most importantly, you can as well share your view on the examples we have covered here or even better still, offer us valuable tips on using this vital command line tool through the comment section below.
How to Use Rsync to Sync New or Changed/Modified Files in Linux的更多相关文章
- External file changes sync may be slow: Project files cannot be watched (are they under network mount?)
if some files are on a mounted disk: go to Settings | Notifications | File Watcher Messages and tune ...
- Linux命令——rsync
参考:Rsync (Remote Sync): 10 Practical Examples of Rsync Command in Linux How to Sync Files/Directorie ...
- 【转载】CentOS 6.3下rsync服务器的安装与配置
一.rsync 简介 Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件,也可以使用 Rsync 同步本地硬盘中的不同目录. Rsy ...
- CentOS 6.3下rsync服务器的安装与配置
一.rsync 简介 Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件,也可以使用 Rsync 同步本地硬盘中的不同目录. Rsy ...
- CentOS6 下rsync服务器配置
一.rsync 简介 Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件,也可以使用 Rsync 同步本地硬盘中的不同目录. Rsy ...
- Server Data Synchronization Via Linux rsync、rsync+inotify Between Load Balance Server
目录 . 远程文件同步的应用场景 . rsync+crontab . rsync+inotify 1. 远程文件同步的应用场景 在负载均衡集群的应用场景中,往往在多台web server的前端有一个提 ...
- rsync 使用示例
导读 Rsync(remote sync) 是用于同步某一位置文件和目录到另一位置的有效方法.备份的位置可以在本地服务器或远程服务器.本站之前亦有介绍rsync的安装配置和教程,详看<rsync ...
- linux服务之rsync
http://www.cnblogs.com/itech/archive/2010/06/13/1757952.html rsync与mfs好像有点类似,都是传输块的chunk,chunk的 1)软件 ...
- rsync常用命令及格式
rsync在同步文件夹内容这个工作上应用非常广泛,但是rsync本身命令还是比较复杂,本文总结一下: rsync = remote sync的简称 ,它 被用于在linux/unix系统中执行备份操作 ...
随机推荐
- C:指针、数据类型、格式化输入输出、输入函数的坑点
指针.数据类型.格式化输入输出.输入函数的坑点 有时候我们迷茫的时候,坚持就是最好的选择. 1.指针的分类为什么很重要? 参考 答:因为指针会根据相应的类型取对应长度的数据,类型决定所取数据的长度.如 ...
- Release 版本和 Debug 版本
什么是 Release 版本.Debug 版本? bug-缺陷,程序故障.而debug指的是排除缺陷,显然这个模式是面向开发者的. 而release是满足发布所用. Debug 和 Release,在 ...
- 【汉字乱码】IE下GET形式传递汉字。
js:encodeURI(); php:urlencode(); 举例: 本来打算这样使用 <a href="list.php?plate=辖区动态" charset=&qu ...
- java懒汉式单例遇到多线程
单例模式确保某个类只有一个实例,而且自行实例化并向整个系统提供这个实例. 在计算机系统中,线程池.缓存.日志对象.对话框.打印机.显卡的驱动程序对象常被设计成单例.这些应用都或多或少具有资源管理器的功 ...
- Ext_两种处理服务器端返回值的方式
1.Form表单提交返回值处理 //提交基本信息表单 f.form.submit({ clientValidation:true, //表单提交后台处理地址 url:' ...
- 如何修改meclipse中的默认浏览器
window------->preferrences------------>general-------------->web browser---------->选择你要使 ...
- xiaoxia的vim配置
这样已经很强大了 set nu sts=4 ts=4 sw=4 et si ai set ruler set hlsearch syntax on filetype plugin on
- 【M17】考虑使用缓式评估
1.缓式评估其实就是拖延战术,直到逼不得已的时候才去计算.缓式评估的使用场景有: 2.引用计数,考虑String,String是一个内含char指针(char指针以'\0'结束)的资源管理类,正常情况 ...
- bzoj 2435: [Noi2011]道路修建 树上 dp
2435: [Noi2011]道路修建 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/pr ...
- Linux中搭建SVNserver
一 下载工具 1. subversion-1.6.17.tar.gz 2. subversion-deps-1.6.17.tar.gz 二 解压两个包: 1.在此之前,我已经创建了一个用户svnroo ...