20+ Rsync command’s switches and common usages with examples – Unix/Linux--reference
reference:http://crybit.com/rsync-commands-switches/
The “rsync” is a powerful command under the Linux environment. The rsync stands for Remote Sync. Normally rsync is used to transfer file from one server(source) to another server(destination). rsync has a lot of switches or option for managing the command much usefully. Here I am explaining the switches of rsync command with examples. Rsync will actually look and see what in the file has changed and upload only the part of the file that has changed. Unlike ftp and other transfer solutions rsync doesn’t simply re-upload the entire file.
Common Syntax for Rsync:
# rsync [options] Source Destinations.
Switches of rsync:
1, -v, –verbose
Increase verbosity.
Example:
I’ve created a file ‘rsync’ under ‘/root/Rsync/’ for testing purpose.
root@server [~]# rsync -v /root/Rsync/rsync .
rsync sent 65 bytes received 31 bytes 192.00 bytes/sec
total size is 0 speedup is 0.00
2, -r, –recursive
Recurse into directories.
3, -l, –links
Copy symlinks as symlinks.
4, -p, –perms
Preserve permissions.
5, -t, –times
Preserve modification times.
6, -g, –group
Preserve group.
7, -o, –owner
preserve owner (super-user only)
8, -D
Same as –devices –specials.
–devices : preserve device files (super-user only).
–specials : preserve special files.
9, -H, –hard-links
Preserve hard links
10, -A, –acls
Preserve ACLs (implies –perms)
11, -X, –xattrs
Preserve extended attributes
12, -a, –archive
This is very important rsync switch, because it can be done the functions of some other switches combinations.
Archive mode; equals -rlptgoD (no -H,-A,-X)
13, -q, –quiet
Suppress non-error messages.
14, To specify the file size for sync:
–max-size=SIZE
Don’t transfer any file larger than SIZE
–min-size=SIZE
Don’t transfer any file smaller than SIZE
15, –delete
Delete extraneous files from destination dirs.
16, W, –whole-file
Copy files whole (without delta-xfer algorithm)
17, -u, –update
Skip files that are newer on the receiver. Means, Do Not Overwrite the Modified Files at the Destination.
18, –progress
View the rsync Progress during Transfer.
19, Include and Exclude Pattern.
–include
–exclude
Patterns are expressed in single quote.
Examples:
[root@ser crybit]# rsync -avz --include 'c*' --exclude '*' /root/crybit/ 109.200.11.67:/root/Rsinc101
root@109.200.11.67's password:
stdin: is not a tty
sending incremental file list
cry1.doc
cry2.doc
cry3.doc
cry4.doc
cry5.doc sent 267 bytes received 107 bytes 68.00 bytes/sec
total size is 0 speedup is 0.00
In the above example files starting with ‘c’ are included for Rsync and all other files are excluded on Rsync operation.
20 -e : Rsync over Shell(SSH)
Syntax:
# rsync -avz -e ssh Source Destination
Some useful switches combinations and Useful “Rsync” examples:
1, How to Sync two directories in the same machine ?
I have created two directories(also some files inside each dir) under /root location to check the rsync usages.
/root/Rsync1/
/root/Rsync2/
Example:
root@server [~]# rsync -zvr /root/Rsync1/ /root/Rsync2/
sending incremental file list
rsync1.txt
rsync10.txt
rsync2.txt
rsync3.txt
......
......
sent 502 bytes received 202 bytes 1408.00 bytes/sec
total size is 0 speedup is 0.00
Where,
-z is to enable compression
-v verbose
-r indicates recursive
2, Preserve the following option while Sync files using -a switch.
r, l, p, t, g, o, D : Switch details are mentioned in the above section.
Recursive mode, symbolic links, permissions, timestamp, owner and group
See the example below:
root@server [~]# ll /root/Rsync1/rsync10.txt
-rw-r--r-- 1 root root 0 Feb 17 07:40 /root/Rsync1/rsync10.txt
root@server [~]# ll /root/Rsync2/rsync10.txt
-rw-r--r-- 1 root root 0 Feb 17 07:40 /root/Rsync2/rsync10.txt
3, How to Rsync files from remote server to local ?
It is quit similar to SCP, the syntax for doing the same is pasted below:
# rsync -azv Remote-IP:/path/for/Sync /Path/to/Sync
Some examples:
Sync the directory from remote to local
[root@ser crybit]# rsync -azv MY.SERVER.IP:/root/Rsync1 /root/crybit/
root@109.200.11.67's password:
stdin: is not a tty
receiving incremental file list
Rsync1/
Rsync1/rsync1.txt
Rsync1/rsync10.txt
Rsync1/rsync2.txt
Rsync1/rsync3.txt
.....
.....
sent 205 bytes received 527 bytes 77.05 bytes/sec
total size is 0 speedup is 0.00
Sync all files from remote to local
[root@ser crybit]# rsync -azv 109.200.11.67:/root/Rsync1/* /root/crybit/
root@109.200.11.67's password:
stdin: is not a tty
receiving incremental file list
rsync1.txt
rsync10.txt
rsync2.txt
rsync3.txt
...
...
sent 201 bytes received 499 bytes 93.33 bytes/sec
total size is 0 speedup is 0.00
4, How to sync files from local to remote server ?
Syntax:
# rsync -azv /local-path/for/Sync/ Remote-IP:/path/to/Sync
Examples:
[root@support crybit]# rsync -avz /root/crybit/ 109.200.11.67:/root/Rsinc101
root@109.200.11.67's password:
stdin: is not a tty
sending incremental file list
created directory /root/Rsinc101
./
rsync1.txt
rsync10.txt
rsync2.txt
rsync3.txt
...
...
sent 1028 bytes received 399 bytes 190.27 bytes/sec
total size is 0 speedup is 0.00
Note 1 : In example 3 and 4 you can use user@IP:/path format, if you have only the user privilege on server
Note 2 : The rsync will automatically create the destination directory/location if it isn't there.
That’s it !! ![]()
Related:
groupdel, groupmems, groupmod, useradd, usermod, chgrp, chown, ls, head, tail, top, ps, find,crontab, ftp commands, tar, rpm,
20+ Rsync command’s switches and common usages with examples – Unix/Linux--reference的更多相关文章
- 15+ tar command usages with examples – Unix/Linux--reference
reference :http://crybit.com/tar-command-usages-with-examples/ The ‘tar’ saves many files together i ...
- 10+ commonly using find command switches with example Unix/Linux
http://crybit.com/find-command-usage-with-example-unixlinux/ find command is one of the best search ...
- 18 Tar Command Examples in Linux
FROM: http://www.tecmint.com/18-tar-command-examples-in-linux/ 18 Tar Command Examples in Linux By R ...
- selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
抓取网页代码后,由于是在同一个li标签下,所以使用一次性抓取,所有的a标签,然后循环做不同的操作,但是抛出找不到元素异常. def office_page(_chrome: Chrome): sn = ...
- 13 Basic Cat Command Examples in Linux(转) Linux中cat命令的13中基本用法
Cat (串联) 命令是Linux/Unix开源系统中比较常用的一个命令.我们可以通过Cat命令创建一个或多个文件,查看文件内容,串联文件并将内容输出到终端设备或新的文件当中,这篇文章我们将会以实例的 ...
- 13 Basic Cat Command Examples in Linux
FROM: http://www.tecmint.com/13-basic-cat-command-examples-in-linux/ The cat (short for “concatenate ...
- 15 Practical Grep Command Examples In Linux / UNIX
You should get a grip on the Linux grep command. This is part of the on-going 15 Examples series, wh ...
- List of Chromium Command Line Switches(命令行开关集)——官方指定命令行更新网址
转自:http://peter.sh/experiments/chromium-command-line-switches/ There are lots of command lines which ...
- Unix/Linux环境C编程入门教程(20) 搭建基于Mac的 Xcode 与 QT 开发环境
1.启动 Vmware,如果没有 VMware 的同学,请看前面我们搭建 VMware 的视频 2.打开虚拟机以后,出现虚拟机界面 3 新建一个虚拟机 4 选择自定义,单击下一步 5 选择默认的 VM ...
随机推荐
- 关于Noise and Error主题的一些小知识
(一)Noise会不会对VC bound产生影响? 此笔记源于台湾大学林轩田老师<机器学习基石><机器学习技法> 答案是不会. 当信号中加入了Noise,其实对我们之前学过的内 ...
- Winxp下搭建SVN服务器
本文介绍一种在winxp下搭建SVN服务器的方法. (1) 需要下载Slik-Subversion和TortoiseSVN两个软件.我使用的版本是Slik-Subversion-1.8.3-1-win ...
- JAVA与多线程开发(线程基础、继承Thread类来定义自己的线程、实现Runnable接口来解决单继承局限性、控制多线程程并发)
实现线程并发有两种方式:1)继承Thread类:2)实现Runnable接口. 线程基础 1)程序.进程.线程:并行.并发. 2)线程生命周期:创建状态(new一个线程对象).就绪状态(调用该对象的s ...
- CSS定位(CSS定位概述、相对定位、绝对定位、浮动)
CSS 定位属性 CSS 定位属性允许你对元素进行定位. 属性 描述 position 把元素放置到一个静态的.相对的.绝对的.或固定的位置中. top 定义了一个定位元素的上外边距边界与其包含块上边 ...
- [apkAnalyzer] 查看APK包名
最近项目中要用到APK的包名,必应到apkAnalyzer这个软件可以用,下载解压后,看到这么些jar,bat文件不知道怎么用. 参考了这篇文章,看的也不甚明白,最后还是试出来了,这里记录一下. 首先 ...
- 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇:简介及目录》(附上完整工程文件)
G-3D引擎2D射击类游戏制作教程 游戏类型: 打飞机游戏属于射击类游戏中的一种,可以划分为卷轴射击类游戏. 视觉表现类型为:2D 框架简介: Genesis-3D引擎不仅为开发者提供一个3D游戏制作 ...
- NotePad++ delphi/Pascal函数过程列表插件
从cnpack上爬下来的 函数过程列表 点击下载
- JSP学习初体验
JSP简介: 1)JSP--Java Server Pages 2)拥有servlet的特性与优点(本身就是一个servlet) 3)直接在HEML中内嵌JSP代码 4)JSP程序由JSP Engin ...
- 提高iOS开发效率的方法和工具
http://www.cocoachina.com/ios/20150717/12626.html 介绍 这篇文章主要是介绍一下我在iOS开发中使用到的一些可以提升开发效率的方法和工具. IDE 首先 ...
- 使用gson进行json转换
Gson 是 Google 提供的用来在 Java 对象和 JSON 数据之间进行映射的 Java 类库.可以将一个 JSON 字符串转成一个 Java 对象,或者反过来. 示例代码如下: 实体定义 ...