rsync MacOS command
The MacOS rsync command is a powerful tool for syncing and transferring files efficiently. It allows users to copy files between local and remote systems with ease, utilizing options for preserving permissions, ownership, timestamps, and more. With rsync, users can sync files and directories, handle partial transfers, and automate backups. This command is especially useful for those looking to mirror directories, copy large amounts of data, or synchronize files between different locations. By mastering the rsync command on MacOS, users can streamline their file management processes and ensure data integrity during transfers.
rsync Syntax:
Options:
Option | Description |
---|---|
-v | Verbose mode, increase verbosity |
-r | Recurse into directories |
-a | Archive mode, archive and preserve attributes |
-z | Compress file data during the transfer |
-h | Output numbers in a human-readable format |
-P | Same as —partial —progress |
-c | Skip based on checksum, not mod-time & size |
-u | Skip files that are newer on the receiver |
-n | Perform a trial run with no changes made |
-q | Quiet mode, suppress non-error messages |
Parameters:
Parameter | Description |
---|---|
SRC | Source file/directory to sync from |
DEST | Destination file/directory to sync to |
rsync bash Examples:
Sync Files and Directories Locally
This command syncs files and directories from a source directory to a destination directory on the local machine.
Sync Files and Directories Remotely over SSH
This command syncs files and directories from a local machine to a remote server over SSH using the rsync command.
Exclude Specific Files or Directories
Excludes a specific directory from the source directory while syncing files using rsync.
Display Progress During Transfer
This command displays the progress of the file transfer while syncing files and directories using rsync.
Delete Files in the Destination Not Present in Source
Syncs files and directories, deleting any files in the destination that are not present in the source directory.
Synchronize Files in Dry Run Mode
Performs a dry run of the rsync command, showing what files would be transferred without actually transferring them.
How do I specify a source and destination with rsync in MacOS?
To specify a source and destination with rsync in MacOS, use the following command:
How do I exclude specific files or directories with rsync in MacOS?
To exclude specific files or directories with rsync in MacOS, you can use the --exclude
option. Here’s an example command:
How can I compress data during transfer using rsync in MacOS?
To compress data during transfer using rsync in MacOS, include the -z
option in your command. Here’s how you can do it:
How do I sync files and directories recursively with rsync in MacOS?
To sync files and directories recursively with rsync in MacOS, add the -r
option to your command. Here’s an example:
How do I delete files from the destination that no longer exist in the source with rsync in MacOS?
To delete files from the destination that no longer exist in the source with rsync in MacOS, include the --delete
option in your command. Here’s how you can do it:
How do I print a verbose output during synchronization with rsync in MacOS?
To print a verbose output during synchronization with rsync in MacOS, add the -v
option to your command. Here’s an example:
How do I preserve file permissions and ownership during synchronization using rsync in MacOS?
To preserve file permissions and ownership during synchronization using rsync in MacOS, include the -p
and -o
options in your command. Here’s how you can do it:
How do I show the progress of the rsync transfer in MacOS?
To show the progress of the rsync transfer in MacOS, you can use the --progress
option. Here’s an example command:
Applications of the rsync command
- Synchronize files between local directories
- Backup files to a remote server
- Copy files with specific permissions and attributes
- Mirror directories while preserving the file structure
- Transfer files securely over SSH
- Exclude certain files or directories from being synchronized