rsync를 사용하여 원격 호스트에서 로컬로 디렉터리를 가져올 수 없습니다.

rsync를 사용하여 원격 호스트에서 로컬로 디렉터리를 가져올 수 없습니다.

내 문제는 내가 해결하려는 더 큰 문제의 작은 부분일 뿐입니다.

문제는 rsyncansible에서 구축한 매우 복잡한 명령으로 시작하여 작동하지 않습니다. 여기에 보고되어 있습니다.

https://stackoverflow.com/questions/73859216/ansible-synchronize-module-fails-to-get-directory-from-remote-to-local-failed

원격 호스트에서 로컬로 폴더를 복사하는 간단한 rsync 명령으로 시작하고 싶습니다.

원격지가 파일이면 복사하지만, 원격지가 디렉터리이면 복사가 실패합니다.

$ /bin/rsync --version
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

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
[mylocaluser@mylocalhost myremotehost]$ uname -a
Linux mylocalhost 3.10.0-1160.76.1.el7.x86_64 #1 SMP Tue Jul 26 14:15:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Rsync는 파일과 함께 작동합니다.

$ /bin/rsync -v myremoteuser@myremotehost:/tmp/Deployments/pay.war /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/

This system is for the use by authorized users only. All data contained
on all systems is owned by the company and may be monitored, intercepted,
recorded, read, copied, or captured in any manner and disclosed in any
manner, by authorized company personnel. Users (authorized or unauthorized)
have no explicit or implicit expectation of privacy. Unauthorized or improper
use of this system may result in administrative, disciplinary action, civil
and criminal penalties. Use of this system by any user, authorized or
unauthorized, constitutes express consent to this monitoring, interception,
recording, reading, copying, or capturing and disclosure.

IF YOU DO NOT CONSENT, LOG OFF NOW.

##################################################################
# *** This Server is using Centrify                          *** #
# *** Remember to use your Active Directory account          *** #
# ***    password when logging in                            *** #
##################################################################

pay.war

sent 43 bytes  received 83 bytes  252.00 bytes/sec
total size is 0  speedup is 0.00

그런데 파일 대신 디렉터리를 제공하면 작동하지 않습니다.

$ /bin/rsync -v myremoteuser@myremotehost:/tmp/Deployments/ /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/

This system is for the use by authorized users only. All data contained
on all systems is owned by the company and may be monitored, intercepted,
recorded, read, copied, or captured in any manner and disclosed in any
manner, by authorized company personnel. Users (authorized or unauthorized)
have no explicit or implicit expectation of privacy. Unauthorized or improper
use of this system may result in administrative, disciplinary action, civil
and criminal penalties. Use of this system by any user, authorized or
unauthorized, constitutes express consent to this monitoring, interception,
recording, reading, copying, or capturing and disclosure.

IF YOU DO NOT CONSENT, LOG OFF NOW.

##################################################################
# *** This Server is using Centrify                          *** #
# *** Remember to use your Active Directory account          *** #
# ***    password when logging in                            *** #
##################################################################

skipping directory .

sent 8 bytes  received 30 bytes  25.33 bytes/sec
total size is 0  speedup is 0.00

제안해주세요.

답변1

에 따르면 rsync --help:

--recursive, -r 디렉토리로 재귀

따라서 디렉토리를 복사하려면 추가하거나 옵션을 선택해야 -r합니다 --recursive.rysnc:

/bin/rsync -rv myremoteuser@myremotehost:/tmp/Deployments/ /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/

답변2

rsync -a일반 대신 사용하십시오 rsync.

-a( ) 플래그가 없으면 --archive재귀적으로 복사할 수도 없고 파일 메타데이터를 가져올 수도 없습니다. mtime복사된 것으로 생각되는 파일을 선택적으로 건너뛰려면 최소한 복사된 파일 수정 시간()이 필요합니다. 원본과 대상에서 파일 크기와 마지막 수정 시간이 동일하다고 판단되면 체크섬을 수행하지 않는 경향이 있지만 분명히 파일 수정 시간을 대상에 복사하지 않으면 일치하지 않으며 전송 알고리즘이 수행할 수 없습니다. 최적화됩니다.-t--timesrsyncrsyncrsync

관련 정보