ArrowLeft Icon

Simplify Your File Synchronization and Backup with Linux Rsync Command

📆 · ⏳ 2 min read · · 👀

Introduction

The rsync command is a powerful tool for file synchronization and backup in Linux. It is a command-line utility that allows you to efficiently synchronize files between two directories on the same or different systems. With rsync, you can keep your files synchronized across multiple devices, create backups, and transfer files securely over the network.

In this article, we’ll explore how the rsync command works and learn how to use it for file synchronization and backups.

Using the Rsync Command

To use the rsync command, you must first have it installed on your Linux system. Most Linux distributions come with rsync pre-installed, but if it’s not installed, you can install it using your package manager.

The basic syntax of the rsync command is as follows:

Terminal window
rsync [options] source destination

Where the source is the directory or file that you want to synchronize or backup, and the destination is the location where you want to store the synchronized or backed up files.

Here are some examples of how to use the rsync command:

Synchronize two directories

To synchronize two directories, use the following command:

Terminal window
rsync -avh /path/to/source /path/to/destination

The -a option preserves the file permissions, ownership, and timestamps, while the -v option displays verbose output, and the -h option displays the file sizes in human-readable format.

Synchronize over SSH

To synchronize files over SSH, use the following command:

Terminal window
rsync -avh -e ssh /path/to/source user@remote:/path/to/destination

The -e option specifies the remote shell to use, and the user@remote specifies the username and hostname of the remote system.

Backup files

To create backups of files, use the following command:

Terminal window
rsync -avh --backup --backup-dir=/path/to/backup /path/to/source /path/to/destination

The --backup option creates backups of files that have changed or been deleted, and the --backup-dir option specifies the directory where backups will be stored.

Conclusion

The rsync command is a powerful tool for file synchronization and backups in Linux. It allows you to efficiently synchronize files between two directories on the same or different systems, transfer files securely over the network, and create backups of files that have changed or been deleted.

With its simple syntax and advanced features, rsync is a must-have tool for anyone who wants to keep their files organized and secure.

EnvelopeOpen IconStay up to date

Get notified when I publish something new, and unsubscribe at any time.

Need help with your software project? Let’s talk

You may also like

  • # linux

    Easily Backup your Local Data to the Cloud in Linux

    In this digital age, securing your precious data is non-negotiable. Let's delve into the world of continuous backups using a nifty tool called rclone, perfect for tech-savvy folks. We'll even set up a backup with Google Drive as an example. Your data's future is in good hands!

  • # linux

    Linux System Logs: An Overview of System Logs and How to Read Them

    Have you ever wondered where all the information about your system's activities and events is stored? Linux system logs contain a wealth of information that can help diagnose and troubleshoot system issues. In this article, we will give an overview of Linux system logs and explain how to read and interpret them.

  • # linux

    Linux RAID Configurations for Data Redundancy and Performance

    RAID is a popular method of combining multiple physical storage devices into a single logical unit, for the purposes of improving data redundancy and/or performance. Linux has a number of built-in tools and configurations for managing RAID setups. In this article, we'll provide an overview of RAID and the different RAID levels, as well as examples of how to configure and manage RAID arrays in Linux.