Skip to content
Advertisement

How to achieve a mirror copy in Linux?

I want to make two directories synchronized. I know there is a robocopy /MIR command in Windows that can achieve this. Ex:

JavaScript

When there is a file updated or deleted, the backup directory can keep synchronization.

I have tried in Linux through the rsync command like this:

JavaScript

but when I delete a file under /usr/test and then run this command, the deleted file still exists in /backup/test — the two directories can’t keep asynchronization. So, how can I achieve the synchronization of two directories in Linux?

Advertisement

Answer

rsync has a --delete option which does what was asked:

JavaScript

It has a lot of related options.

Further reading:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement