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 . rsyncsent 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.docsent 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,
转载于:https://www.cnblogs.com/davidwang456/p/3602554.html
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 ...
- YUM更换源(1)--yum找不到安装包 2013-01-18 20:08 8687人阅读 评论(1) 收藏 举报 分类: linux(70) 公司提供的CentOS VM中,/etc/yum.r
YUM更换源(1)--yum找不到安装包 2013-01-18 20:08 8687人阅读 评论(1) 收藏 举报 分类: linux(70) 公司提供的CentOS VM中,/etc/yum.rep ...
- linux ls in*,35 ls Command Examples in Linux (The Complete Guide)
Do you know how to list contents (files/directories) in Linux? It's straightforward. In this article ...
- selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element
在输入框输入内容,点击[查询],然后点击页面上的[处理],并进行点击时,报错,报错内容如下. selenium.common.exceptions.StaleElementReferenceExcep ...
- Using command line switches to fix Outlook 2010 not Responding
不知道什么原因,Outlook 2010突然不work了,邮件和todo等几个区域老显示Loadin就不动了.查了一轮也没查到什么好办法或者解释,可能是因为这个现象太普遍,原因太多了. 不经意看到有个 ...
- edk2编译报错 BrotliCompress.c:20:10: fatal error: ./brotli/c/common/constants.h: No such file or directo
近期github上的edk2版本有些问题 edk2\BaseTools\Source\C\BrotliCompress\brotli edk2\MdeModulePkg\Library\BrotliC ...
- unix linux tecn,对高级 Linux 用户有用的 20 个下令
31. Command: rm The command 'rm' stands for remove. rm is used to remove files (s) and directories. ...
- linux原生系统_Ubuntu GamePack 20.04系统发布:通吃8.6万款Linux/Win/DOS游戏
与Windows相比,Linux系统不被人接受的一大缺陷就是游戏支持,但这已经是老黄历了,现在专为游戏优化的Ubuntu GamePack 20.04系统,可以畅玩8.6万款游戏. 看名字就知道,Ub ...
最新文章
- uboot给内核传参的方式——tag
- 微软职位内部推荐-Senior Development Lead – Sharepoint
- 数据可视化(BI报表的开发)第四天
- 在Hibernate的session中同时有两个相同id的同类型对象,修改失败
- 一起谈.NET技术,Silverlight 应用整合
- 微mysql命令行_mysql命令大全
- Leetcode:11.container-with-most-water(盛水最多的容器)
- 4月1号鸿蒙系统上线,4月1日太关键,鸿蒙迎来正式发布前的最后大考,华为将从此起飞...
- 算法导论 思考题4-1
- 在windows上删除linux文件夹,java-如何从Linux删除远程Windows中的文件夹
- shiro—登录拦截
- python和java md5加密,如何将javamd5加密代码移植到Python中?
- 计算机ip保留地址,分类ip地址中,保留地址有哪些?具体点说说,作业。
- HTML5和CSS3新增
- Eclipse更换炫酷黑色主题
- sap服务器安装双系统教程,安装双系统教程,新手入门必看教程
- led灯条串联图_10个LED灯并联再串联
- codevs 2147 数星星
- 如何在word中粘贴美观工整的代码段(planetB/notepad++)
- EWSTM8系列教程06_工程节点选项配置(一)
热门文章
- php jcrop,PHP结合JQueryJcrop实现图片裁切实例详解
- dva的用法_dva.js 用法详解:列表展示
- oracle获取堆栈,如何从RAISED异常中获取oracle PL / SQL中原始异常的堆栈跟踪?
- Qt中的基础图形绘制
- 西工大与东北大学计算机,国内世界高水平大学排名:西北工业大学位居第一,东北大学排第二...
- mysql jdbc 协议_JDBC-MySql
- j2ee html5,HTML5+J2EE实现文件异步上传
- tensorflow2.0 与tensorflow1.0的性能区别
- 通过先序和中序数组生成后续数组
- 针对连续动作的DQN