我正在尝试使用 rundeck 将 docker 容器卷中的文件同步到异地服务器。我可以模拟 rundeck 用户并在终端窗口中运行 rsync 命令就好了。
当 rundeck 执行相同的命令时,我将收到Unexpected Remote Arg错误或Unexpected Local Arg错误,具体取决于我在命令中放置--rsync-path选项的位置。如果我省略 --rsync-path我会收到权限被拒绝错误,因为文件位于 docker 卷中并且需要 root 访问权限。
注意:命令和输出已被编辑,但在其他方面是准确的
以用户 rundeck 的身份在 rundeck 服务器上的终端中执行 rsync 命令:
rsync -avP rundeck@remotehost:/var/lib/docker/volumes/dockervolumename/_data /srv/destination/backup_datetime --rsync-path="sudo rsync"
命令输出:
receiving incremental file list
created directory /srv/destination/backup_datetime
_data/
_data/storage/
_data/storage/upload/
_data/storage/uploads/
_data/storage/uploads/admin/
_data/storage/uploads/group/
sent 48 bytes received 203 bytes 100.40 bytes/sec
total size is 0 speedup is 0.00
同一命令(本地命令)的 rundeck 调试输出:
13:56:50 [workflow] Begin step: 1,NodeDispatch
13:56:50 1: Workflow step executing: StepExecutionItem{type='NodeDispatch', keepgoingOnSuccess=false, hasFailureHandler=false}
13:56:50 preparing for sequential execution on 1 nodes
13:56:50 Executing command on node: localhost, NodeEntryImpl{tags=[], attributes={nodename=localhost, hostname=***, osVersion=8, osFamily=linux, osArch=x64, description=Offsite backup server @ ***, osName=CentOS}, project='null'}
13:56:50 [workflow] beginExecuteNodeStep(localhost): NodeDispatch: StepExecutionItem{type='NodeDispatch', keepgoingOnSuccess=false, hasFailureHandler=false}
13:56:50 LocalExecNodeStepPlugin, running command (6): 'rsync''-avP''rundeck@remotehost:/var/lib/docker/volumes/dockervolumename/_data''/srv/destination/backup_datetime''--rsync-path="sudo''rsync"'
13:56:50 Unexpected local arg: /srv/destination/backup_datetime
13:56:50 If arg is a remote file/dir, prefix it with a colon (:).
13:56:50 rsync error: syntax or usage error (code 1) at main.c(1368) [Receiver=3.1.3]
13:56:50 Failed: NonZeroResultCode: Result code was 1
13:56:50 [workflow] finishExecuteNodeStep(localhost): NodeDispatch: NonZeroResultCode: Result code was 1
13:56:50 1: Workflow step finished, result: Dispatch failed on 1 nodes: [localhost: NonZeroResultCode: Result code was 1 + {dataContext=MultiDataContextImpl(map={}, base=null)} ]
13:56:50 [workflow] Finish step: 1,NodeDispatch
我已经验证 rundeck 可以通过 ssh 密钥与目标服务器交互并在那里运行命令。
rsync 和 rundeck 之间是否存在某种我缺少的交互?
我是 rundeck 和 rsync 的新手。据我所知,我得到的错误通常是由于命令中的语法错误而发生的。原始命令在终端中运行良好,因此让我相信 rundeck 以某种方式混淆了它。
源服务器是在 OpenStack 环境中运行 CentOS 7 的 VM。
目标服务器是在外部网络上运行 CentOS 8 的 VM。