I can't fathom why rsync isn't working...

Here's my directory and contents...

$ pwd

$ ls
'~'      neomutt          tmux   vit     gitconfig    mbsyncrc   myclirc              taskrc   tmux.conf        vimrc     zshrc
 drush   remote-servers   vim    ackrc   khard.conf   msmtprc    ptpython_config.py   tigrc    tmuxinator.zsh   xinitrc

and here's my backup command...

rsync -avvr --exclude='view' /home/alec/.dotfiles /media/alec/storage/dotfiles

After running that command, the destination files are un-changed...

$ pwd

$ ls
drush  hiddendrush  vim  gitconfig  tmux.conf  tmuxinator.zsh  vimrc  xinitrc  zshrc

I don't know how any more simple it could be. The --exclude='view' is because there's some contents in there that breaks the rsync command and that subdirectory's not needed anyway. What could be the problem?

When I type the command rsync prints to the terminal the entire contents of the source directory, hundreds of files, but they don't get copied to the destination. Why?


The problem lies in the command

rsync -avvr --exclude='view' /home/alec/.dotfiles /media/alec/storage/dotfiles

This takes the directory .dotfiles in /home/alec and copies it to directory /media/alec/storage/dotfiles, where it becomes /media/alec/storage/dotfiles/.dotfiles. This directory is not shown by ls unless you write ls -A

The command you want is

rsync -avvr --exclude='view' /home/alec/.dotfiles/ /media/alec/storage/dotfiles/

Note the addition of two trailing slashes. This will recursively copy everything in /home/alec/.dotfiles/ into /media/alec/storage/dotfiles/

  • Thaaaank youuuuu <3 – alec Aug 12 '20 at 2:11
  • Don't forget to clean up your extra directory. – David G. Aug 12 '20 at 2:13
  • The slash at the end of the destination path is unimportant. The slash at the end of the source path is important. – Kusalananda Aug 12 '20 at 5:33
  • @Kusalananda True, but probably worth doing anyway. It does make a difference if you have a single source file. With the slash, it makes directory and uses the source file's name therein. Without the slash, it doesn't make a directory and uses the exact name specified. (It is actually a bit inconsistent. rsync -a a b will make b/a/... if a is a directory, and just file b if a is a file.) – David G. Aug 12 '20 at 14:56

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.