It's best to leave the pattern matching to rsync, then you're not depending on whatever shell and options that shell has at that time.
When you do:
rsync -a /some/dir/* host:/remote/dir/
then you're actually asking the shell to expand the /some/dir/*
part, so that rsync is actually executed like this:
rsync -a /some/dir/adir /some/dir/afile /some/dir/anotherfile [etc] host:/remote/dir/
This is usually quite similar to what the intention was, however not always as demonstrated by the fact that this question was asked. Hence it's better to execute:
rsync -a /some/dir/ host:/remote/dir/
Now rsync will (because -a
is shorthand for -rlptgoD
which includes -r
for recursion) recursively walk through the /some/dir
directory and sync all its contents to /remote/dir
on the remote host, including any dot files directly in /some/dir
.
As the source path ends with a slash /
, the filenames transferred omit any part of the source location. If /some/dir
was passed, then you're telling to explicitly sync the dir
directory, including its name. It's recommended to get into the habit of adding the last slash at all times to avoid such confusion, unless you really understand what's going on.