To make a complete backup of your system, RSYNC, which stands for “Remote Sync,” is a powerful open-source tool that allows efficient synchronization and backup of files between two locations. To provide this technical description, several reliable sources such as Linux.com, Indeed.com and Man7.org will be used.
RSYNC uses the incremental file transfer algorithm to synchronize files between two locations. This means it only transfers the files that have been altered, resulting in faster transfers and efficient use of resources.
Here is the basic command structure: `rsync options source destination`. Source and destination can be either local or remote. Options are used to define what you want rsync to do.
Let’s break down an example:
```
rsync -avz /home/user/documents/ /media/backup/documents/
```
This command will back up the ‘documents’ directory in ‘user’ to an external drive mounted at ‘/media/backup/documents/’. The ‘-avz’ flag is a combination of three options:
- ‘a’ (short for ‘archive’) ensures that the files and directories are copied recursively with permissions and other important metadata preserved.
- ‘v’ (verbose) means rsync will display details of the ongoing operation.
- ‘z’ (compression) compresses data during the transfer.
For greater reliability, you can use the ‘—delete’ option to remove files on the destination end that no longer exist at the source:
```
rsync -avz —delete /home/user/documents/ /media/backup/documents/
```
To back up the entire system, the source would be the root directory. However, excluding certain directories for efficiency is common. Here is an example where ‘/proc’, ‘/sys’, ‘/tmp’, ‘/mnt’, ‘/dev’, and ‘/backup’ directories are excluded:
```
rsync -aAXv —delete —exclude=/proc/ —exclude=/sys/ —exclude=/tmp/ —exclude=/mnt/ —exclude=/dev/ —exclude=/backup / /path/to/backup/folder/
```
RSYNC can also be used to synchronize files remotely over SSH. In the following example, the ‘-e’ flag is used to specify ssh as the remote shell:
```
rsync -avz -e ssh /home/user/documents/ user@remote:/home/user/backup/
```
This use of rsync can also support Two-Factor Authentication (2FA) and Public Key Infrastructure (PKI), ensuring the secure handling of data during the transfer.
RSync is an essential command-line tool for system administrators for data backup and sync. While there is a learning curve to understanding its extensive options and functionality, its power, flexibility, and efficiency make it a tool of choice for many.
Sources:
- Linux.com (https://www.linux.com/training-tutorials/using-rsync-backup-your-data-linux/)
- Rsync User Guide (https://download.samba.org/pub/rsync/rsync.html)
- Man7.org (https://man7.org/linux/man-pages/man1/rsync.1.html)