rsync를 사용하여 디렉터리를 원격 USB 펜 드라이브에 올바르게 복사하는 방법

rsync를 사용하여 디렉터리를 원격 USB 펜 드라이브에 올바르게 복사하는 방법

권한을 수정하지 않고 이 디렉터리를 운영 체제에 복원할 수 있도록 Debian 11의 디렉터리 트리를 원격 펜 드라이브로 어떻게 복사할 수 있나요?

USB 펜 드라이브가 /home/<user>/mntPC에 설치되어 있습니다 <host>. 디렉토리의 권한과 펜 드라이브의 형식은 다음과 같습니다.

$ ls -la ./mnt
drwxrwxrwx 1 root root 16384 Jan  1  1970 .
drwxr-xr-x 3 <user> <user>  4096 Mar 21 20:10 ..

$ sudo fdisk -l | grep sdb
Partition 3 does not start on physical sector boundary.
Disk /dev/sdb: 29,85 GiB, 32027705344 bytes, 62554112 sectors
/dev/sdb1        2048 62554111 62552064 29,8G 83 Linux

그런 다음 설치했습니다.떨어져서USB 펜 드라이브( /home/<user>/mnt) 사용 방법 /mnt/remoteusb:

$ sudo sshfs -o allow_other,default_permissions <user>@<host>:/home/<user>/mnt /mnt/remoteusb

$ ls -la /mnt/remoteusb/
drwxrwxrwx 1 root root 16384 Jan  1  1970 .
drwxr-xr-x 3 root root  4096 Mar 20 22:52 ..

이를 설정한 후 rsync를 통해 파일 복사를 시도했지만 수정 권한이나 타임스탬프가 없었음에도 불구하고 여전히 다음 세 가지 유형의 경고(13, 95, 74)를 받았습니다.

$ sudo rsync -aAXHv /var/lib /mnt/remoteusb --log-file=/home/user/rsynclog.log --no-perms --omit-dir-times | grep failed

rsync: [receiver] chown "/mnt/remoteusb/lib/gdm3/.local/share/gvfs-metadata/.root.S3P7V1.j1LLd2" failed: Permission denied (13)
rsync: [receiver] rsync_xal_set: lsetxattr("/mnt/remoteusb/lib/systemd/.random-seed.oerYo2","user.random-seed-creditable") failed: Operation not supported (95)
rsync: [receiver] mkstemp "/mnt/remoteusb/lib/ucf/cache/.:etc:apt:apt.conf.d:50unattended-upgrades.ustIa1" failed: Bad message (74)

답변1

SSHF를 사용하면 <user>연결을 설정하는 데 사용하는 권한에 따라 권한이 제한됩니다. 실제로 sshfs를 전혀 사용할 필요가 없습니다.

rsync를 직접 사용하는 것이 좋습니다(내부적으로는 ssh도 사용함). 아래와 같이 로컬과 서버 측 모두에서 루트 사용자를 사용해야 합니다.

sudo rsync -aAXHv /var/lib root@<host>:/root/mnt

관련 정보