Rsync for making copies

2023.06.09   •   1 min read

There are so many uses and options with rsync, it’s mind-boggling. After some searching and manual reading, I arrived at a command that I use.

So many times I want to keep an extra copy of some important files on a couple of external drives. Here is a command I arrived at:

rsync -avhWxS --no-compress --progress --info=progress2 <input file> <output directory>
# additional option that is sometimes needed:
# --delete-after

Options used:

  • -a archive
  • -v verbose (I prefer more info displayed)
  • -h human readable file sizes
  • -W copy files whole
  • -x don’t cross filesystem boundaries
  • -S turn sequences of nulls into sparse blocks
  • the danger option: --delete-after delete extraneous files from the destination after the transfer of the new files (not during)

The above command became two aliases in my ~/.zshrc file (or your shell file):

alias rsync-my="rsync -avhWxS --no-compress --progress --info=progress2"
alias rsync-my-delete="rsync -avhWxS --no-compress --progress --info=progress2 --delete-after"

Note: this command is finicky with slashes at the end of source and destination directories to make sure to test it out with no deleting to see where the source files (or directories) are being sent. A "control - c" shortcut can exit the command if the files are not being put where you intended. Then, remove or add the “/” after the destination folder if the copy is one directory level off. I admit, with rsync, that has happened to me and so I learned.

Say Hi!


Page last modified: 2023.06.09.