10 Rsync useful applications

   |   3 minute read   |   Using 485 words

Here are 10 useful commands for rsync

Whether you’re a seasoned system administrator or just getting started with managing your files, these ten rsync commands will prove to be invaluable tools in your toolkit.

1. Basic Local Copy

When it comes to copying data locally, simplicity is key. The following command will perform a straightforward local copy from the /source/directory to the /destination/directory, while preserving file attributes:

rsync -av /source/directory /destination/directory

2. Copy/Sync Directory Locally

Sometimes you need to copy or synchronize an entire directory and its contents locally. To achieve this, use the following command:

rsync -av /source/directory/ /destination/directory

This command ensures that all files and subdirectories within /source/directory are mirrored in /destination/directory.

3. Copy Files & Directories Recursively Locally

For more complex synchronization tasks that involve recursive copying of files and directories, rsync has you covered. Execute the following command to achieve a comprehensive local copy:

rsync -avR /source/directory /destination/directory

With the -R option, rsync will maintain the directory structure and copy files and subdirectories recursively.

4. Backup During Synchronization

Data safety is paramount, and rsync offers a convenient backup feature. This command ensures that backups are created while synchronizing data from /source/directory to /destination/directory:

rsync -av --backup /source/directory /destination/directory

Your precious data is preserved, and you have a safety net with backup copies.

5. Update Only

Keeping your files up to date is a common task. The following command ensures that only newer files in /source/directory are copied to /destination/directory:

rsync -av -u /source/directory /destination/directory

When dealing with symbolic links, it’s essential to maintain their integrity. Use this command to copy symlinks as symlinks from /source/directory to /destination/directory:

rsync -av -l /source/directory /destination/directory

This preserves the symbolic links, ensuring your file structure remains consistent.

7. Dry Run

Before executing a synchronization task, it’s wise to perform a dry run to preview the changes without actually altering any files. Use this command:

rsync -av --dry-run /source/directory /destination/directory

You can review the potential changes before committing to the synchronization.

8. Compress File Data During Transfer

Efficiency matters when transferring data over a network. To compress file data during transfer, employ this command:

rsync -avz /source/directory /destination/directory

The -z option enables data compression, reducing bandwidth usage during synchronization.

9. Display Output Numbers in Human-Readable Format

When monitoring your synchronization process, human-readable output is helpful. This command ensures that output numbers are presented in a readable format:

rsync -avh /source/directory /destination/directory

10. Show Sync Progress During Transfer

For real-time insights into the progress of your synchronization, use this command:

rsync -av --progress /source/directory /destination/directory

You’ll receive updates on the transfer status, providing transparency into the ongoing operation.

With these ten rsync commands at your disposal, you’ll have the capability to efficiently manage your data synchronization tasks, whether you’re copying, backing up, or updating files and directories. Mastering these commands will empower you to navigate the world of data management with ease.



denis256 at denis256.dev