无法使用远程同步(rsync)

问答中心分类: OneinStack无法使用远程同步(rsync)
Asttear 提问 3月 前

如题,已确认两边都已安装 rsync
spawn /usr/bin/ssh -o GSSAPIAuthentication=no -q -lasttear -p10022 server.xxx
[email protected]\’s password:

BusyBox v1.29.3 (2019-01-08 18:11:56 CST) built-in shell (ash)
Enter \’help\’ for a list of built-in commands.
[RT-N56U_B1 /opt/home/admin]# 2019-02-28 17:35:52 — 2019-02-28 17:35:57
./mabs.sh –excutes over!
spawn rsync -crazP –delete –bwlimit=1024000 -e /usr/bin/ssh -o GSSAPIAuthentication=no -q -lasttear -p10022 /data/backup/DB_ast_20190228_17.tgz i.asttear.xyz:/data/backup
[email protected]\’s password:
sh: rsync: not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.2]
OK_SCP: server.xxx
rsync 情况:
本机:
[email protected]:~|⇒ apt install rsync
Reading package lists… Done
Building dependency tree
Reading state information… Done
rsync is already the newest version (3.1.2-2.1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[email protected]:~|⇒ rsync
rsync version 3.1.2 protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, prealloc
远程(备份)服务器:
[RT-N56U_B1 /media/Router/backup]# opkg install rsync
Package rsync (3.1.3-2) installed in root is up to date.
[RT-N56U_B1 /media/Router/backup]# rsync
rsync version 3.1.3 protocol version 31
Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
no socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, prealloc

7 问题
oneinstack 回答 3月 前

which rsync 看下rsync命令路径在哪里? 
是否在/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin 这些路径下?

Asttear 回答 3月 前

[RT-N56U_B1 /opt/home/admin]# which rsync
/opt/bin/rsync
[email protected]:~|⇒  which rsync
/usr/bin/rsync
备份服务器实际上是刷了 Padavan 的路由器,因此是 Optware 的环境。和这个有关吗?

oneinstack 回答 3月 前

/usr/bin/rsync是正常的,/opt/bin/rsync需要自己改path路径,可如下操作:
/root/oneinstack/tools/mscp.exp 中rsync 改成绝对路径 /opt/bin/rsync

Asttear 回答 3月 前

将此文件的4个 rsync 全部修改为了路由器上的绝对路径:
spawn /opt/bin/rsync -crazP –delete –bwlimit=$bwlimit -e “/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port” $ip:$sourcefile $destdir
spawn /opt/bin/rsync -crazP –delete -e “/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port” $ip:$sourcefile $destdir
终端重复
spawn /usr/bin/ssh -o GSSAPIAuthentication=no -q -lasttear -p10022 server.xxx
Ctrl + C 结束后报错:
couldn’t execute “/opt/bin/rsync”: no such file or directory
    while executing
“spawn /opt/bin/rsync -crazP –delete –bwlimit=$bwlimit -e “/usr/bin/ssh -o GSSAPIAuthentication=no -q -l$user -p$port” $sourcefile $ip:$destdir”
    (“for” body line 17)
    invoked from within
“for {} {1} {} {
  # for is only used to retry when “Interrupted system call” occured
 
  if { $direction == “pull” } {
 
    if { $bwlimit > 0 } {
     …”
    (file “./mscp.exp” line 39)

oneinstack 回答 3月 前

恢复之前mscp.exp,在backup.sh 中加入以下:

export PATH=/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
Asttear 回答 3月 前

#!/bin/bash# Author: yeho <lj2007331 AT gmail.com># BLOG: https://blog.linuxeye.cn## Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+## Project home page:# https://oneinstack.com# https://github.com/oneinstack/oneinstack
export PATH=/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# Check if user is root…加在了最前面,依旧报错

sh: rsync: not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.2]
OK_SCP: server.xxx

 

CTRL + C 后提示: 

 [email protected]:~/oneinstack|⇒  error writing “stdout”: broken pipe    while executing”puts “OK_SCP: $ip\n””    invoked from within”expect {  “assword:” {    send “$passwd\r”    puts “\nPASSWORDERROR: $ip Password error!!!\n”    exit 1  }   eof {    puts “OK_SCP: $ip\n”    …”    (file “./mscp.exp” line 147) 

oneinstack 回答 3月 前

这个就真不知道了。。没整过路由器 openwrt