0

I try to sync the source directory to a destination directory that is mounted inside the source directory. I run the command:

rsync -avP /folder/with/files /destination_directory

I can see the destination directory but after a while, and while the rsync command is still running, it disappears.

Any ideas why this might happen and what I am doing wrong?

5
  • Could you say anything else about the source and target paths? Are they remote or local? Can you show what the actually are? Can you describe what you mean by "cannot find it" (does the destination directory disappear?). Can you copy-paste a transcript of you showing what's happening?
    – Kusalananda
    Mar 30 '20 at 14:55
  • @Kusalananda Thank you for your reply. The source path is local and the target path is remote to a server mounted to my source path. The destination directory disappears after a while. I am able to see it for some time but after a while it disappears.
    – sart
    Mar 31 '20 at 7:40
  • @sart Umm... So you are syncing the source directory to somewhere that is mounted inside the source directory? You need to add that to the question and explain exactly where the destination directory is mounted. Also make sure that the command is exactly the command that you use (there are two rsync on the line and there is no indication that /destination lies within /folder).
    – Kusalananda
    Mar 31 '20 at 7:43
  • @Kusalananda I have edited the question. Thanks for the tips.
    – sart
    Mar 31 '20 at 7:58
  • Try adding -x to stop rsync entering the mounted destination directory.
    – Kusalananda
    Mar 31 '20 at 8:19
0

Syncing a source directory that contains the destination directory is never a good thing. I can't tell you exactly why the destination directory appears to be disappearing, but it probably has something to do with trying to replicate the directory recursively.

To avoid this, use rsync with its -x or --one-file-system option. This stops rsync from entering other filesystems on the source side other than the filesystem that the top-level source directory is located on.

This would however not work if the destination directory is mounted as a "bind mount" inside the source directory. In that case, you may instead explicitly exclude the destination directory with --exclude=/destination_directory (I can't unfortunately tell you what path to use with --exclude here as you are not showing the actual paths in your command in the question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.