2016-10-05 1 views
-2

외부 드라이브의 폴더를 끝 사이 배쉬 rsync를 명령은 다른 행동을 가지고 및 DestinationFolder 로컬 폴더 (둘 다 내 MAC에)로 제대로 작동합니다. 의미는 새로운 파일을 복사하고 최신 버전을 DestinationFolder에 덮어 씁니다.

외부 드라이브 폴더를 DestinationFolder로 사용하여 스크립트를 실행하면 SourceFolder의 전체 내용을 복사하여 덮어 씁니다.

매번 SourceFolder의 전체 내용 대신 최신 버전의 파일 만 덮어 쓸 수있게하려면 어떻게해야합니까?

답변

0

왜 대답이 이미 어딘가에 있기 때문에 나는 이것이 왜 downvoted인지 전혀 알지 못합니다. 어쨌든 나는 충분히 구체적인 질문이라고 생각했다.

여기 몇 시간 후 내 스크립트를 수정 한 방법이 있습니다. 키는 --update--modify-window=1 rsync 명령 옵션에 있습니다.

작동하는 스크립트는 다음과 같습니다 (외부 파일에서 파일을 제외시키고 있음).

#!/bin/sh 

ScriptName=${0##*/} 

# this script sync SourceFolder with DestinationFolder 
# to a FAT32 external drive, excluding files from ExcludeFile 

### --- EDIT FOLDERS HERE --- ### 
SourceFolder='/Users/matteo' 
DestinationFolder='/Volumes/HITACHI/MatteoMainFolderBackup' 
ExcludeFile='/Users/matteo/.backupignore' 

### --- DISPLAY SOME INFO --- ### 
echo "Starting " $ScriptName 
printf "WARNING! This script sync all files from SourceFolder to DestinationFolder \n" 
echo "SourceFolder: " $SourceFolder 
echo "DestinationFolder: " $DestinationFolder 
echo "ExcludeFile: " $ExcludeFile 
printf "### Start Syncing files ###\n" 

### --- OPERATIONS --- ### 
rsync --archive \ 
     --delete \ 
     --delete-excluded \ 
     --exclude-from=$ExcludeFile \ 
     --modify-window=1 \ 
     --progress \ 
     --update \ 
     --verbose \ 
     $SourceFolder/ $DestinationFolder 

### --- END --- ### 
echo $ScriptName " ended" 
관련 문제