Forrest logo
back to the rsync tool

rsync:tldr:c4191

rsync: Transfer a directory [r]ecursively, in [a]rchive (to preserve attributes), resolving contained sym[L]inks, and ignoring already transferred files [u]nless newer.
$ rsync -rauL ${remote_host}:${path-to-remote_directory} ${path-to-local_directory}
try on your machine

The rsync command is a powerful file synchronization and transfer tool in Linux. Let's break down the given command:

rsync: This is the command to start the rsync process.

-rauL: These are the options/flags passed to the rsync command. Each flag has a specific purpose:

  • -r or --recursive: Tells rsync to recurse into directories, copying all files and subdirectories present.
  • -a or --archive: Enables the archive mode, which preserves permissions, timestamps, symbolic links, and other special attributes of files and directories.
  • -u or --update: Skips any files on the receiving end that are newer than the ones on the sending end. This option makes the sync process more efficient.
  • -L or --copy-links: Copies the referent of symbolic links instead of copying the link itself.

${remote_host}:${path-to-remote_directory}: This specifies the remote host and the path to the remote directory from which files need to be copied. Replace ${remote_host} with the hostname or IP address of the remote server, and ${path-to-remote_directory} with the path to the directory you want to sync from the remote server.

${path-to-local_directory}: This specifies the local destination where the files will be synchronized. Replace ${path-to-local_directory} with the path to the local directory where you want to save the copied files.

In summary, the given rsync command recursively synchronizes files from a remote host's directory to a local directory, preserving permissions, timestamps, and symbolic links. It also skips files that already exist in the destination and are newer than the ones on the source.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the rsync tool