rsync

rsync in shell for loop

喜你入骨 提交于 2019-12-31 03:31:07
问题 I have this shell script #!/bin/sh PATHS=( a b c d ) for PATH in ${PATHS[@]} do rsync -avziP /home/user/$PATH $SERVER:$server_folder -b --backup-dir=$backup_folder/backup_$date --delete --exclude=.* --log-file=$HOME/rsync.log done And I always get this error: rsync: command not found What is driving me crazy is that if I delete the for loop, and just run the rsync command, the script works perfectly 回答1: PATH is a reserved variable! It is the variable specifying where to search tools (like

lsyncd实时同步搭建指南——取代rsync+inotify

北慕城南 提交于 2019-12-30 21:38:23
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> lsyncd实时同步建指南——取代rsync+inotify 1. 几大实时同步工具比较 1.1 inotify + rsync 最近一直在寻求生产服务服务器上的同步替代方,原先使用的是inotify + rsync,但随着文件数量的增大 到100W+,目录下的文件列表就达20M,在网络状况不佳或者限速的情况下,变更的文件可能10来个才几M,却因此要发送的文件列表就达20M,严重减 低的带宽的使用效率以及同步效率;更为要紧的是,加入inotifywait在5s内监控到10个小文件发生变化,便会触发10个rsync同步操作,结 果就是真正需要传输的才2-3M的文件,比对的文件列表就达200M。使用这两个组合的好处在于,它们都是最基本的软件,可以通过不同选项做到很精确的控 制,比如排除同步的目录,同步多个模块或同步到多个主机。 建过程参 Linux下同步工具inotify+rsync使用详解 。 1.2 sersync 后来听同事说 sersync 这么个工具可以提高同步的性能,也解决了同步大文件时出现异常的问题,所以就尝试了一下。sersync是国内的一个开发者开源出来的,使用c++编写, 采用多线程的方式进行同步,失败后还有重传机制,对临时文件过滤,自带crontab定时同步功能。网上看到有人说性能还不错

rsync , rsync + ssh, rsync + lsyncd 多种同步方案与比较

梦想的初衷 提交于 2019-12-30 21:28:39
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1. 利用 ssh+rsync 只需要在服务器端打开 ssh 服务, 并启动 xinetd 中 rsync 服务则可使用 a. 增量同步 rsync -av /src-dir/. user@ipadress:/dest-dir/ . b. 镜像同步 rsync -av --delete /src-dir/. user@ipadress:/dest-dir/ . 特点: 配置简单, 不需要配置 rsyncd.conf 配置文件, 但需要在同步过程中进行用户认证 注: 利用 expact + gzipexe 可以创建自动同步加密脚本 使用: 可手动同步或每天晚上定制时间任务同步 缺点:无法实现实时同步, 不可以成为双机热备份方案么 2. 启用 rsync 服务 需要配置 /etc/rsyncd.conf 配置文件, 需要启动 xinetd 中 rsync 服务, 可以不通过 sshd 协调 a. 配置文件 (参考 man 5 rsyncd.conf , 目录共享管理参考 smb.conf) rsyncd.conf 参考 motd file = true # 时间记录 pid file = /var/run/rsyncd.pid port = 873 address = 0.0.0.0 log file = /var

技巧:Linux rsync 同步由手动到自动

故事扮演 提交于 2019-12-30 21:20:43
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> rsync 是一个快速增量文件传输工具,它可以用于在同一主机备份内部的备分,我们还可以把它作为不同主机网络备份工具之用。本文主要讲述的是如何自架rsync 服务器 ,以实现文件传输、备份和镜像。相对tar和wget来说,rsync 也有其自身的优点,比如速度快、安全、高效; 手动的: 首先要建立好两台服务器之间的公钥和密钥,那样就不需要每次都输入密码,也可以实现自动了。 可以先使用rpm -qa |grep rsync 查看rsync是否已经安装, 软件 下载 Rysnc的主页地址为:http://rsync.samba.org/ 本试验的测试环境(2台,一个服务端,一个客户端) rsync服务端的ip:192.168.48.60 rsync客户端的ip:192.168.48.148 ----------------------------------------------- 以下先配置服务器端: 1. 安装rsync包 # rpm -q rsync rsync-2.6.3-1 2. rsync只使用一个配置文件就是/etc/rsyncd.conf 这个文件一般是没有的,那就自己建一个好了 # vi /etc/rsyncd.conf uid = nobody gid = nobody max

rsync配置两台服务器之间的文件备份(同步)

懵懂的女人 提交于 2019-12-30 21:01:51
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> rsync配置两台服务器之间的文件备份(同步) 前情提要 环境: 192.168.1.2 主服务器 centos 7.7 192.168.1.3 备份服务器 centos 7.7 rsync 安装(两台linux都需要安装) 在linux环境下,以centos为例,安装非常简单: [root@qinshengfei ~]# yum install rsync rsync的配置文件(服务端配置) rsync 服务端安装完成之后是没有生成rsync.conf文件的,需要手动创建rsyncd.conf [root@qinshengfei ~]# vim /etc/rsyncd.conf #先定义整体变量 secrets file = /etc/rsyncd.secrets #配置同步用户名和密码 motd file = /etc/rsyncd.motd read only = yes list = yes #uid = nobody #gid = nobody uid = root gid = root hosts allow = * #哪些电脑可以访问rsync服务 hosts deny = 0.0.0.0/32 #哪些电脑不可以访问rsync服务 max connections = 2 log file =

Rsync启动停止脚本

情到浓时终转凉″ 提交于 2019-12-30 05:46:13
网上找了个完善的rysnc启停脚本: http://linux5588.blog.51cto.com/65280/779000 rsync源码: [root@lanny d4]# cat rsync_start_restart.sh #!/bin/sh if [ "$1" == "restart" ];then [ -f /var/run/rsyncd.pid ] && kill `cat /var/run/rsyncd.pid` /bin/rm -f /var/run/rsyncd.pid && rsync --daemon Fi    首次执行: [root@lanny d4]# sh -x rsync_start_restart.sh restart + '[' restart == restart ']' + '[' -f /var/run/rsyncd.pid ']' + /bin/rm -f /var/run/rsyncd.pid + rsync --daemon 第二次执行 [root@lanny d4]# sh -x rsync_start_restart.sh restart + '[' restart == restart ']' + '[' -f /var/run/rsyncd.pid ']' ++ cat /var/run/rsyncd.pid + kill

How to show the rsync --progress in web browser using DJango?

我们两清 提交于 2019-12-30 04:57:06
问题 I am writing a Python/Django application which transfer files from server to the local machine using rsync protocol. We will be dealing with the large files so the progress bar is mandatory. --progress argument in rsync command does this beautifully. All the detail progresses are shown in the terminal. How can I show that progress in web browser? Is there any hook function or something like that? Or Can I store the progress in a log file, call it and update it every one minute or so? 回答1: The

Why do bash parameter expansions cause an rsync command to operate differently?

删除回忆录丶 提交于 2019-12-29 09:13:50
问题 I am attempting to run an rsync command that will copy files to a new location. If I run the rsync command directly, without any parameter expansions on the command line, rsync does what I expect $ rsync -amnv --include='lib/***' --include='arm-none-eabi/include/***' \ --include='arm-none-eabi/lib/***' --include='*/' --exclude='*' \ /tmp/from/ /tmp/to/ building file list ... done created directory /tmp/to ./ arm-none-eabi/ arm-none-eabi/include/ arm-none-eabi/include/_ansi.h ... arm-none-eabi

RSync: How do I synchronize in both directions?

人盡茶涼 提交于 2019-12-29 02:32:39
问题 I want to use rsync to synchronize two directories in both directions. I refer to synchronization in classical sense ( not how it is meant in rsync manuals): I want to update the directories in both directions , depending on which of them is newer . Can this be done by rsync (preferable in a Linux-way) ? If not, what other solutions exist? 回答1: Just run it twice, with "newer" mode (-u or --update flag) plus -t (to copy file modified time), -r (for recursive folders), and -v (for verbose

给定两个目录树,如何找出哪些文件有所不同?

﹥>﹥吖頭↗ 提交于 2019-12-28 18:27:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 如果我想找到两个目录树之间的差异,我通常只执行: diff -r dir1/ dir2/ 这准确地输出了相应文件之间的差异。 我有兴趣只获取内容不同的相应文件列表。 我认为这只是将命令行选项传递给 diff ,但我在手册页上找不到任何内容。 有什么建议? #1楼 我使用的命令是: diff -qr dir1/ dir2/ 它与马克的完全相同:)但是他的回答让我困扰,因为它使用了不同 类型 的旗帜,它让我看了两次。 使用Mark的更详细的标志,它将是: diff --brief --recursive dir1/ dir2/ 当其他答案完全可以接受时,我为发布而道歉。 无法阻止自己...努力减少迂腐。 #2楼 我喜欢使用 git diff --no-index dir1/ dir2/ ,因为它可以显示颜色的差异(如果你在git配置中设置了该选项),并且因为它显示了长页面输出中的所有差异“减”。 #3楼 频道同胞'账单'(freenode /#centos成名)与我分享他的方法: diff -Naur dir1/ dir2 包括最终目录正斜杠无关紧要。 此外,似乎 -u 选项在某些较旧/服务器版本的diff上不可用。 差异的差异: # diff -Nar /tmp/dir1 /tmp/dir2/ diff -Nar