Master the Linux ‘rsync’ Command: A Comprehensive Guide

Peter Hou
2 min readMay 10, 2023

--

This article provides a comprehensive guide to the Linux rsync command. It covers its history, its usage, its parameters, along with its most common use cases, and some advanced techniques. Understanding the rsync command is essential for effective data management and backup operations in Linux, making it an indispensable command to learn.

Instructions

This article provides a comprehensive guide to the ‘rsync’ command in Linux. It covers its history, reasons for its use, its detailed usage methods, and an overview of its parameters. The guide also explores common use cases and advanced usage techniques of the ‘rsync’ command.

History

The ‘rsync’ command, short for ‘remote synchronization’, was first released in 1996. It’s a free utility that synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate.

When and why to use it

‘rsync’ is used to copy and synchronize files/directories remotely as well as locally in Linux/Unix systems. Its major use is in backup operations and mirroring.

How to use it

The basic syntax of the ‘rsync’ command is rsync options source destination.

rsync -zvh backup.tar /tmp/backups/

The commonly used parameters

The ‘rsync’ command has numerous parameters. The most commonly used ones are:

  • -a stands for 'archive', which syncs directories recursively and preserves symbolic links, file permissions, user & group ownerships, and timestamps.
rsync -a /source/directory /destination/directory
  • -z compresses data during the transfer, which speeds up the synchronization.
rsync -az /source/directory /destination/directory

Other supported parameters

Other parameters supported by the ‘rsync’ command include:

  • -v increases verbosity.
  • -h outputs numbers in a human-readable format.
  • -e specifies the remote shell to use.
  • --delete deletes extraneous files from destination directories.
  • --exclude excludes files matching a pattern.

Most common use cases

One of the most common use cases for the ‘rsync’ command is to backup files and directories.

rsync -az /source/directory /backup/directory

The tricky skills

An advanced usage of ‘rsync’ is to set up scheduled backups using crontab.

0 0 * * * rsync -az /source/directory /backup/directory

What needs to be noted

One point to note about using ‘rsync’ is that it requires both read and write permissions on the source and destination directories, respectively.

Conclusion

The ‘rsync’ command is a powerful tool in Linux, mainly used for copying and synchronizing files and directories remotely and locally. Learning to use it effectively is an excellent addition to your Linux command line skills.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Peter Hou
Peter Hou

Written by Peter Hou

I am a Senior Software Engineer and tech lead in a top tech company.

No responses yet

Write a response