Why does rsync behaviour with include/exclude differ with and without trailing slash on source directory
by Shaggy1 from LinuxQuestions.org on (#5FF4J)
System info
----------------
Local machine:
$ cat /etc/centos-release
CentOS release 6.8 (Final)
$uname -a
Linux 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ /usr/bin/rsync --version
rsync version 3.0.6 protocol version 30
Remote machine:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
$ uname -a
Linux 2.6.32-358.23.2.el6.x86_64 #1 SMP Sat Sep 14 05:32:37 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
$ /usr/bin/rsync --version
rsync version 3.0.6 protocol version 30
------------------
Hi
I've been setting up some sync scripts and in doing so noticed some behaviour regarding include/exclude in rsync that I am confused about.
If I run an rsync command like this:
Code:$ /usr/bin/rsync -avz --include='.*' --exclude='*' user@host.domain.com:/home/user/ /tmprsyncprac/homeit copies only hidden files and directories of /home/user directly in to the /tmprsyncprac/home directory - as I expected
But the same command without the final slash on the source directory:
Code:$ /usr/bin/rsync -avz --include='.*' --exclude='*' user@:host.domain.com/home/user /tmprsyncprac/homeseems to exclude everything
I was expecting this to copy only hidden files and directories of /home/user to /tmprsyncprac/home/user
And if I remove the include and exclude arguments it does indeed copy all files to /tmprsyncprac/home/user
Does anyone know why the second command excludes everything ?
Does anyone know how I can specify the second command such that only hidden files in /home/user are copied to /tmprsyncprac/home/user


----------------
Local machine:
$ cat /etc/centos-release
CentOS release 6.8 (Final)
$uname -a
Linux 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ /usr/bin/rsync --version
rsync version 3.0.6 protocol version 30
Remote machine:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
$ uname -a
Linux 2.6.32-358.23.2.el6.x86_64 #1 SMP Sat Sep 14 05:32:37 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
$ /usr/bin/rsync --version
rsync version 3.0.6 protocol version 30
------------------
Hi
I've been setting up some sync scripts and in doing so noticed some behaviour regarding include/exclude in rsync that I am confused about.
If I run an rsync command like this:
Code:$ /usr/bin/rsync -avz --include='.*' --exclude='*' user@host.domain.com:/home/user/ /tmprsyncprac/homeit copies only hidden files and directories of /home/user directly in to the /tmprsyncprac/home directory - as I expected
But the same command without the final slash on the source directory:
Code:$ /usr/bin/rsync -avz --include='.*' --exclude='*' user@:host.domain.com/home/user /tmprsyncprac/homeseems to exclude everything
I was expecting this to copy only hidden files and directories of /home/user to /tmprsyncprac/home/user
And if I remove the include and exclude arguments it does indeed copy all files to /tmprsyncprac/home/user
Does anyone know why the second command excludes everything ?
Does anyone know how I can specify the second command such that only hidden files in /home/user are copied to /tmprsyncprac/home/user