rsync 하위 폴더를 다른 폴더 이름으로

rsync 하위 폴더를 다른 폴더 이름으로

내가 이것을 할 때 :

rsync folder/a /mnt/some/destination

결국 얻지만 /mnt/some/destination/folder/a내가 원하는 것은 folder/a콘텐츠다곧장안에 /mnt/some/destination.

다음과 같이 하면 가능하다는 것을 알고 있습니다.

rsync folder/a/* /mnt/some/destination

그러나 문제의 핵심은 이 --delete옵션에는 적용되지 않는다는 것입니다. 이 옵션을 사용하려면 소스가 디렉터리여야 하므로 와일드카드는 작동하지 않습니다.

해결책은

cd folder/a && rsync --delete . /mnt/some/destination

작업 디렉토리를 변경하지 않고 이를 수행할 수 있는 방법이 있습니까? 내 시나리오는 CD/CI 빌드 환경입니다.

tar -C, 또는 같은 옵션이 있나요 wget --cut-dirs?

답변1

바꾸다:

rsync folder/a  /mnt/some/destination

사용:

rsync folder/a/ /mnt/some/destination

이렇게 하면 --delete소스에 존재하지 않는 대상의 파일을 삭제하고 내용 folder/a/mnt/some/destination/.

관련 정보