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系统中执行备份操作 ...
随机推荐
- 在Button的click事件中引起客户端JavaScript
void action1_Execute(object sender, SimpleActionExecuteEventArgs e) { WebWindow.CurrentRequestWindow ...
- 你真的会玩SQL吗?实用函数方汇总
http://www.cnblogs.com/zhangs1986/p/4917800.html 实用函数方法 由于有些知识很少被用到,但真需要用时却忘记了又焦头烂额的到处找. 现在将这些‘冷门“却有 ...
- Delphi Data Types
http://docwiki.embarcadero.com/RADStudio/XE6/en/Delphi_Data_Types Integer Data Types Type Descriptio ...
- JSON的解析
一:JSON字符串转换为JSON对象 JSON 最常见的用法之一,是从 web 服务器上读取 JSON 数据(作为文件或作为 HttpRequest),将 JSON 数据转换为 JavaScript ...
- 【转】知道创宇研发技能表v2.1
转自:http://blog.knownsec.com/Knownsec_RD_Checklist/v2.1.html# 知道创宇研发技能表v2.1 创建时间:2012/12/1 2013/4/26 ...
- 【M25】将构造方法和非成员方法虚化
1.所谓虚化,就是根据引用或者指针的真实类型,决定调用哪个方法. 2.构造方法虚化,就是根据引用(或者指针)的真实类型,构造出一个对象,如果指针的真实类型是Base,返回Base*:如果指针的真实类型 ...
- 使用PageHeap.EXE或GFlags.EXE检查内存越界错误 (转)
2011-05-27 20:19 290人阅读 评论(0) 收藏 举报 microsoftdebuggingstructureoutputimagefile 必先利其器之一:使用PageHeap.EX ...
- SIP入门(二):建立SIPserver
在我的上一篇文章中已经介绍怎样通过SIP软电话直接通话,可是假设须要支持很多其它用户互相通话,同一时候基于安全考虑,须要对用户帐户登录进行验证控制,这些情况下就须要建立SIPserver. SIPse ...
- 安卓高手之路之 WindowManager
安卓中的画面不是纯粹由window组成.而是改成了window+view的组织模式.window是一个顶层窗口的概念.view就相当于在window内的控件.而subwindow则是依附于window ...
- Linux/RedHat 编译安装GNU gcc 4.9.0 (g++)
这里说的是编译安装,yum/apt-get 等安装方法比較简单,不阐述! 1.下载源代码包:gcc.gnu.org 2.解压: tar -xjvf gcc-4.9.0.tar.bz2 3.下载编译所需 ...