![rsync 관련 "읽기 전용 파일 시스템(30)" 오류](https://linux55.com/image/84080/rsync%20%EA%B4%80%EB%A0%A8%20%22%EC%9D%BD%EA%B8%B0%20%EC%A0%84%EC%9A%A9%20%ED%8C%8C%EC%9D%BC%20%EC%8B%9C%EC%8A%A4%ED%85%9C(30)%22%20%EC%98%A4%EB%A5%98.png)
참고: 이는 오류가 발생하는 이유와 해결 방법이라는 두 부분으로 구성된 질문입니다. ('왜' 질문에 대한 대답이 '어떻게' 질문을 드러낼 수 있기 때문에 두 부분은 서로 연관되어 있습니다.)
내가 시도하는 명령은 rsync -avuz /some/source/directory .
(대략) 형식의 몇 가지 오류를 제공합니다
rsync: symlink "/target/directory/foo/bar/baz" -> "../../bar/baz" failed: Read only file system (30)
... /target/directory
현재 디렉터리가 있는 곳입니다.
이 오류 때문에 혼란스러워요. rsync
프로세스에 쓰기 권한이 없다는 것은 사실이지만 ../..
애초에 왜 그렇게 해야 하는지 이해가 되지 않습니다. 확실히 쓰기 권한이 있습니다 /target/directory/foo/bar/baz
.
그러나 현재의 경우 이 문제가 있는 파일 수는 복사되는 전체 파일의 작은 부분에 불과하므로 이러한 문제가 있는 심볼릭 링크를 일반 파일에 "복사"하면 괜찮을 것입니다.이름그 특별한 성격을 나타내기 위해 어떤 방식으로든 변경되었으며,콘텐츠원래 심볼릭 링크의 대상만 포함합니다. 예를 들어 심볼릭 링크
/some/source/directory/foo/bar/baz -> ../../bar/baz
이전에 표시된 콘텐츠는 "복사"됩니다.일반 파일
/target/directory/foo/bar/baz-PSEUDOSYMLINK
...다음과 같은 줄로 구성됩니다.
../../bar/baz
Unix 디렉토리 트리를 Windows 시스템에 복사할 때 비슷한 일이 발생하는 것을 본 적이 있습니다.
이를 수행하는 쉬운 방법이 있습니까?
답변1
질문
나는 내 음악 컬렉션( ) 을 오래된(따라서 오류가 발생하기 쉬운) 하드 드라이브( )에 rsync
백업하여 이를 사용합니다 ./mnt/Music/
crontab
/mnt/Music_Backups
crontab
이 백업 파티션을 수동으로 확인한 후 수동 백업 시도와 마찬가지로 이러한 백업이 때때로(실행되는 경우 자동으로) 실패하는 것을 발견했습니다 .
sudo rsync -aq --delete /mnt/Music/ /mnt/Music_Backups
rsync: [generator] failed to set times on \
"/mnt/Music_Backups/ROCK & POP": Read-only file system (30)
평가하다
내 시스템 세부 정보는 다음과 같습니다.
- 운영 체제: 아치 리눅스 x_86.
rsync
버전 v3.2.3/etc/crontab
입구:
# /etc/crontab entry
0 5 * * * root nice -n 19 rsync -aq --delete /mnt/Music/ /mnt/Music_Backups
장치, 파티션, 마운트 지점을 확인합니다.
lsblk | grep -B1 -i music_back
sdd 8:48 1 1.8T 0 disk
└─sdd1 8:49 1 1.8T 0 part /mnt/Music_Backups
blkid | grep sdd1
/dev/sdd1: LABEL="Music_Backups" \
UUID="b90047d3-147c-491c-a17d-17763f79a12a" \
BLOCK_SIZE="4096" TYPE="ext4" \
PARTLABEL="Music_Backups" \
PARTUUID="98425256-c626-41f1-a85e-6f5feaf412d6"
이유
대상 드라이브 권한은 양호하지만 rsync
다음을 수행한 후에도 동일한 오류가 발생했습니다.
sudo chown -R root:victoria /mnt/Music_Backups/
... 디스크 파티션 유틸리티( ) Gparted
에서는 파티션이 괜찮아 보이지만 명령줄 fsck
유틸리티에서는 실제로 오류가 있음을 보여줍니다.
sudo umount /mnt/Music_Backups/
## Note: if any programs, e.g. a file manager, are using / viewing
## that partition you won't be able to `umount` it until you navigate
## away from anything accessing `/mnt/Music_Backups/`
## Update/CAUTION: do not run fsck on a Network Attached Storage (NAS)
## hard drive (commonly sold on AMZN ...); these require special
## software; fsck will kill your HDD.
sudo fsck /dev/sdd1
fsck from util-linux 2.36
e2fsck 1.45.6 (20-Mar-2020)
Music_Backups: recovering journal
Music_Backups contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inode 85460709 extent tree (at level 1) could be shorter. Optimize<y>? yes
Pass 1E: Optimizing extent trees
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Music_Backups: ***** FILE SYSTEM WAS MODIFIED *****
Music_Backups: 164762/122101760 files (19.8% non-contiguous), 423271337/488378368 blocks
## Recheck:
sudo fsck /dev/sdd1
fsck from util-linux 2.36
e2fsck 1.45.6 (20-Mar-2020)
Music_Backups: clean, 164762/122101760 files, 423271337/488378368 blocks
sudo mount /dev/sdd1 /mnt/Music_Backups/
sudo rsync -aq --delete /mnt/Music/ /mnt/Music_Backups
$ ## completed normally
결론적으로
이를 바탕으로 내 OS가 파티션에서 오류를 감지하면 해당 오류가 해결될 때까지 해당 파티션에 대한 읽기 및 쓰기를 차단하여 rsync
작업을 완료하지 못하게 한다고 생각합니다.
노트
rsync
:
-a
[archive]: 와 동일합니다-rlptgoD
. 재귀적이고 거의 모든 것을 유지하고 싶다는 것을 표현하는 단축키입니다... [https://linux.die.net/man/1/rsync 참조]-q
[quiet] : 오류가 아닌 메시지를 억제합니다.
부록 1: 실패 알림
앞서 언급했듯이 etc/crontab
백업 예약아무 말 않고 실패. 이 문제에 대한 해결책은 다음과 같습니다(에 추가됨 /etc/crontab
).
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
# add this as one line (broken here, for readability;
# substitute your user name for "victoria"):
0 5 * * * victoria nice -n 19
rsync -aq --delete /mnt/Music/ /mnt/Music_Backups ; EXIT_STATUS=$?;
if [ $EXIT_STATUS -ne 0 ]; then
notify-send -i warning -t 0 "/etc/crontab for rsync'd Music Backups failed"
--icon=dialog-information ;
mutt -s "/etc/crontab for rsync'd Music Backups failed" <your_email_address>; fi
이렇게 하면 나중에 백업이 실패할 경우 화면 알림과 이메일을 통해 알림을 받게 됩니다.
https://bash.cyberciti.biz/guide/The_exit_status_of_a_command
https://stackoverflow.com/questions/20449543/shell-equality-operators-eq
notify-send
mutt
및 사용 시 몇 가지 문제가 있다는 점에 유의하세요 /etc/crontab
.
일반 사용자
root
(예: "victoria")로 실행하면 알림이 표시되지 않으며 해당 사용자mutt
의root
이메일 계정을 구성 해야 합니다.crontab
따라서 일반 사용자로 항목을 실행하는 것이 훨씬 쉽습니다.chown
백업 위치를 재귀적으로 설정했기root:victoria
때문에crontab
해당 항목을 "victoria"로 실행하는 것은 문제가 되지 않습니다.위에서 언급한 대로
notify-send
via를 실행하려면/etc/crontab
상단 근처에 다음 줄이 필요합니다/etc/crontab
.
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
echo $UID
일반 사용자(예: "victora" (me))로 터미널에서 실행하여 숫자(위의 "1000")를 가져옵니다.
자세한 내용은 다음을 참조하세요.
- https://bbs.archlinux.org/viewtopic.php?id=216912
- https://wiki.archlinux.org/index.php/Desktop_notifications#Usage_in_programming
그럼에도 불구하고 내 crontab
항목(위)은 매일 아침 오전 5시에 실행되며, 어떤 이유로든 백업이 실패하면 나에게 알려줍니다(화면, 이메일).
이 항목을 사용하여 이러한 명령을 테스트 할 수 있습니다 crontab
(1분마다 실행됩니다. "apples"는 프로그램이 아니므로 확실히 실패합니다).
* * * * * <your_user_name> nice -n 19
apples -aq --delete /mnt/Music/ /mnt/Music_Backups ; EXIT_STATUS=$?;
if [ $EXIT_STATUS -ne 0 ]; then
notify-send -i warning -t 0 "/etc/crontab for rsync'd Music Backups failed"
--icon=dialog-information ;
mutt -s "/etc/crontab for rsync'd Music Backups failed" <your_email_address>; fi
부록 2: 실패 알림
[victoria@victoria ~]$ date
Wed Jan 6 08:48:38 AM PST 2021
[victoria@victoria ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
sdd 8:48 1 1.8T 0 disk
└─sdd1 8:49 1 1.8T 0 part /mnt/Music_Backups
...
[victoria@victoria ~]$ sudo umount /mnt/Music_Backups/
## Update/CAUTION: do not run fsck on a Network Attached Storage (NAS)
## hard drive (commonly sold on AMZN ...); these require special
## software; fsck will kill your HDD.
## Repair disk partition [accept default Y/n suggestions, if present]:
[victoria@victoria ~]$ sudo fsck /dev/sdd1
fsck from util-linux 2.36.1
e2fsck 1.45.6 (20-Mar-2020)
Music_Backups: recovering journal
Music_Backups contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Music_Backups: 165909/122101760 files (20.0% non-contiguous), 425759721/488378368 blocks
## Repeat until no errors:
[victoria@victoria ~]$ sudo fsck /dev/sdd1
fsck from util-linux 2.36.1
e2fsck 1.45.6 (20-Mar-2020)
Music_Backups: clean, 165909/122101760 files, 425759721/488378368 blocks
[victoria@victoria ~]$ sudo mount /dev/sdd1 /mnt/Music_Backups/
## /etc/crontab entry (broken over lines here for readability):
0 5 * * * victoria nice -n 19
rsync -aq --delete /mnt/Music/ /mnt/Music_Backups ; STATUS=$? ;
if [ $STATUS -ne 0 ]; then notify-send -i warning -t 0 "/etc/crontab
for rsync'd Music Backups failed" --icon=dialog-information ;
mutt -s "/etc/crontab for rsync'd Music Backups failed" [email protected] ;
fi
## Check: manually run Music_Backup command
[victoria@victoria ~]$ time rsync -aq --delete /mnt/Music/ /mnt/Music_Backups
0:39.91
[victoria@victoria ~]$