I am trying to backup some files on another drive using rsync
.
As a test case, I am trying the following command:
rsync -Rav --delete --stats /home/my_user/bin* "$dest"
This command will copy files and directories (with their contents) present in my $HOME
directory and having names like ~/bin
, ~/binb
, ~/bin1
, ~/bin2
, etc. to the destination.
However, when I delete any of the files or directories called ~/bin1
or ~/bin2
for example, these are not deleted in the destination too. The only thing that works is when there is a file in a directory say ~/bin2/file1
and this file is deleted, then this file is also deleted in the destination (but not in the case when the directory ~/bin2/
is removed altogether).
Obviously this problem is created by the shell expanding /home/my_user/bin*
to all the file and directory names starting with bin
in my $HOME
directory at the time the rsync
command is executed. So, I tried to quote the source like "/home/my_user/bin*"
, but in this case I get the error:
rsync: [sender] link_stat "/home/my_user/bin*" failed: No such file or directory (2)
What options are needed, so, I can use wildcards for the source(s) and I will have the exact replica of the source file and directory structure, also in the destination?
Note: rsync version 3.2.3 protocol version 31