centos - Is rsync overwriting my `./` directory?

04
2013-09
  • hatorade

    I'm new to rsync, but I've noticed that at the top of the "receiving incremental file list" is ./

    Is rsync overwriting the destination's ./ directory? The timestamp of ./ in destination matches the source, so I assume it is, and I can't seem to prevent this using --exclude './' or --exclude '*/'

    Code:

    rsync -av user@host:/dir1/dir2/ /dir3/dir4/dir5/dir6
    

    In pseudocode, I'm trying to rsync all the files inside dir2 on host into dir6 on the local machine.

  • Answers
  • ernie

    ./ and ../ are OS shortcuts, created by default.

    ./ is just a shortcut to the current working directory, so it's timestamp will always match the timestamp of the directory you're looking at.

    As you're using the archive flag, timestamps will be preserved, and thus match the source.

  • Roberto Gomez

    Can you post the exact command you're running? It would help to know what options you're specifying along with the source and destination directories. Sounds to me like you are confused with the source entry. You need to specify if you would like to sync the contents of the source directory or the entire directory itself. Per the manual documentation:

    A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this direc‐ tory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the con‐ taining directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:

              rsync -av /src/foo /dest
              rsync -av /src/foo/ /dest/foo
    

  • Related Question

    osx - Rsync: Only preserve meta (time, group, etc) on files and sub-directories, not root directory
  • Svish

    I am copying some files (all except hidden ones) using rsync from one place to another using this command:

    rsync -Cav --delete --exclude=.* /Some/Directory/ other-host:/Other/Directory
    

    It works nice except that I get the following errors:

    rsync: chgrp "/Other/Directory/." failed: Operation not permitted (1)
    rsync: failed to set times on "/Other/Directory/.": Permission denied (13)

    That is understandable because I do in fact not have those permissions, and I also do not want to change the group of that directory. I only want to do this for all the files and directories that are in that directory. Is there any way to solve this? Tried to --exclude=. and --exclude=./, but those didn't work.

    Any ideas? I have no idea how to fix this...


    More details: This is on Mac OS X, and the directories I am syncing is from a local mounted volume to the /Users/Shared/ directory on the other host. That directory has user root and group wheel. The files inside it has user admin and group staff and so does the local source directory.


    Temporar solution: Still curious how I can solve this, but since I don't know how to do that yet, I "solved" this by using a different directory than /Users/Shared for those files.


  • Related Answers
  • David Spillett

    If you know that other-host:/Other/Directory already exists you could try:

    rsync -Cav --delete --exclude=.* /Some/Directory/* other-host:/Other/Directory/
    

    then it shouldn't try to do anything with the root directory other than create files/dirs in it.