Skip to content

rsync -- a fast, versatile, remote (and local) file-copying tool

Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It offers a large number of options that control every aspect of its behavior and permit very flexible specification of the set of files to be copied. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. Rsync is widely used for backups and mirroring and as an improved copy command for everyday use.

Rsync finds files that need to be transferred using a lqquick checkrq algorithm (by default) that looks for files that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file's data does not need to be updated.

Some of the additional features of rsync are:

  • support for copying links, devices, owners, groups, and permissions
  • exclude and exclude-from options similar to GNU tar
  • a CVS exclude mode for ignoring the same files that CVS would ignore
  • can use any transparent remote shell, including ssh or rsh
  • does not require super-user privileges
  • pipelining of file transfers to minimize latency costs
  • support for anonymous or authenticated rsync daemons (ideal for mirroring)

Note

Rsync copies files either to or from a remote host, or locally on the current host (it does not support copying files between two remote hosts). More info at: https://linux.die.net/man/1/rsync


Story

After many back-up solutions, I've found the best one that suits my needs. One that copy the "raw" files instead of making of compressing it with non-standard tools. (my assumption) so when I need to get those files back, I can open the File Explorer and copy it right back, without installing the back-up program itself.

The way I use Rsync is very simple... let me explain the explain the options.

  • a is for archiving [0]
  • v is for verbosity
  • h is human readable
  • p is preserve permission
rsync -avhp --exclude-from="/home/guillermo/rsyncexclude.txt" /home/guillermo/ /media/guillermo/SAMSUNG_256_NVME/MAGGIERAW

The reason why I increase verbosity is to exclude files and folders I don't need back-up. I don't need to back-up .cache so that directory is going on the exclude list.

And also it's easier to keep up which files and directories to exclude instead of typing everything in the terminal emulator.

Rsyncexclude.txt

An example what to exclude:

node_modules
.cache
.config
.local
.npm
.nvm

For Windows

rynsc.ps1 (Powershell executable)

Slightly different for Windows utilizing Cygwin

Cygwin is a collection of open source tools that allows Unix or Linux applications to be compiled and run on a Microsoft Windows operating system (OS) from within a Linux-like interface.

And is required to run Rsync.

https://www.cygwin.com/install.html

https://community.chocolatey.org/packages/Cygwin

You can copy the command or copy the command in a file.

rsync -ahvp --exclude-from="/cygdrive/c/Users/guill/rsyncexclude.txt" "/cygdrive/c/Users/guill/" "/cygdrive/D/GUILLERMO_LATEST"

Rsyncexclude.txt (Windows)

An example what to exclude:

AppData/Local/Packages
AppData/Local/
"C:\Users\guill\VirtualBox VMs"
.vscode/extensions/*
AppData/Roaming/Code/
AppData/Roaming/EaseUS/*
AppData/Roaming/*
AppData/LocalLow/*
VirtualBox VMs/
.vagrant.d/*
.config/
.vscode

[0] What is archive mode in Rsync

Simple and stupid, but it works flawlessly, no time to waste.

Done