Eva Cheung
Eva Cheung

Reputation: 119

Sync from dir1 and dir2, and keep the two directory same

I want to sync from source directory to local directory, I used to use command: rsync -av /path1/dir1 /path2/dir2 and it will add the contents of dir1 to dir2.

However, I want to keep dir1 and dir2 same. I do not hope someone else can add files to dir2 without using rsync command (Means want to delete other contents that not belongs to dir1 when sync from dir1 to dir2)

Thanks!

Upvotes: 0

Views: 156

Answers (1)

jraynal
jraynal

Reputation: 517

According to the documentation:

    --delete                delete files that don’t exist on sender

So, the following should work:

rsync -av --delete /path1/dir1 /path2/dir2

Upvotes: 1

Related Questions