An Important command in linux:)

rsync command

  • rsync is a command-line utility in Unix/Linux systems that allows you to synchronize files and directories between different locations. It can be used for local or remote backups, and it supports many options to customize the synchronization process.

  • To backup an entire directory to another location using rsync, you can use the following command:

rsync -avz /path/to/source/directory/ /path/to/destination/directory/

Some very important options of rsync in Linux :

  • -a: archive mode, which is a shortcut for several options that preserve permissions, ownership, timestamps, and recursive copying. This option is commonly used for backups because it ensures that all the metadata and subdirectories of the files are preserved during the copy.

  • -v: verbose mode, which shows the progress and details of the synchronization process. When this option is used, rsync prints a list of files as they are transferred, along with their transfer rate and any errors that occur.

  • -z: compress files during transfer, which can save bandwidth and speed up the transfer if the files are compressible. This option is useful when transferring large files over a slow network connection.

  • -r: recursive mode, which causes rsync to copy directories and their contents recursively. This option is useful when you want to copy a directory and all its subdirectories.

  • -n: dry-run mode, which shows what rsync would do without actually copying any files. This option is useful for testing and debugging rsync commands before actually executing them.

  • -u: update mode, which only copies files that are newer than the destination files or don't exist in the destination. This option is useful when you want to synchronize two directories and avoid copying unnecessary files.

  • --delete: delete files in the destination directory that don't exist in the source directory. This option is useful for creating a mirror backup of a directory, where the destination directory only contains files that exist in the source directory.

Did you find this article valuable?

Support Gaurav-Jethuri by becoming a sponsor. Any amount is appreciated!