I regularly, but manually, rsync a certain local directory (A) to a remote machine. More than once I have rsynced in the wrong direction and deleted stuff that was new in A. I have backups but it takes some time to restore.

To avoid stupid mistakes like this I thought that I could mount A somewhere else in my local file system (B) and as READ ONLY so in case I perform the sync in the wrong direction nothing happens. Can this be done?

  • 1
    Why not do a “dry run” first with the -n or —dry-run flags to ensure your issuing the correct command?
    – Allan
    Jun 15, 2023 at 16:06
  • 1
    Is there a reason you don't want to put this in a script - to avoid confusing SOURCE & DESTINATION?
    – Seamus
    Jun 15, 2023 at 17:52
  • 1
    apple.stackexchange.com/questions/197029/… seems to have an answer for this.
    – nohillside
    Jun 16, 2023 at 10:59
  • @Seamus I have a script but you still have to give the right command.
    – d-b
    Jun 16, 2023 at 16:10
  • 1
    @d-b: You said that you "regularly, but manually" rsync... if you have a script, how can you get SOURCE & DEST reversed occasionally?
    – Seamus
    Jun 16, 2023 at 19:46

1 Answer 1


I don't understand your question, but rather than flog that with more comments, perhaps you should consider using the --backup-dir=DIR option in your rsync command.

See man rsync for details, but essentially what the option does is to save all files & directories that would otherwise be deleted in the DESTINATION location to the folder designated in the --backup-dir=DIR option statement.

How would that help? Assuming your script uses an argument to set SOURCE and DESTINATION, add some if-else code that invokes the --backup-dir=DIR option statement whenever your DESTINATION is the local directory A.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .