How to use Rsync on OmniOS/OpenIndiana
Rsync is a powerful utility for efficiently transferring and synchronizing files across computer systems, using a delta transfer algorithm to minimize network usage. It supports various options for copying files securely and efficiently, making it widely used for backups and mirroring. Rsync operates both in client-server mode and in a standalone mode for local file copying.
┌
Open a terminal and switch to root
su -
┌
Install rsync on both client and server machines:
(you'll probably have to choose between 2 repos for the package, take the distribution repo first)
pkg install rsync
┌
Generate and share an SSH key
(without passphrase) for secure connections.
┌
Basic Rsync commands
To send a file to the server :
rsync -avzP -e "ssh -p 47689" /local/path file remoteuser@remoteserver:/destination/path
To fetch a file from the server:
rsync -avzP -e "ssh -p 47689" remoteuser@remoteserver:/source/path /local/dest/path/
┌
More Options :
Compression: Use
--compress-level=9
for maximum compression.Exclusion/Inclusion: Use
--exclude='*.tmp'
to exclude,--include='*.txt'
to include.Bandwidth Limit: Use
--bwlimit=1000
to limit network usage to 1000KB/s.Logging: Use
--log-file=rsync.log
for detailed tracking.Dry Run: Add
--dry-run
to simulate transfers.
┌
Security and Performance Tips:
Use
--checksum
for content-based verification rather than relying on timestamps and file sizes.Integrate specific SSH options for enhanced security, like
-oCiphers=...
.For efficient backups, consider leveraging ZFS snapshots.
Here's an example command that incorporates several of the above elements, designed for quick use in most scenarios :
rsync -avzP --compress-level=9 --exclude='*.tmp' --bwlimit=1000 --log-file=rsync.log -e "ssh -p 47689 -oCiphers=aes256-gcm@openssh.com" /local/path/ remoteuser@remoteserver:/destination/path/
Explanations :
-avzP
: Enables archive mode to preserve permissions, compresses during transfer, and shows progress.
Be carefull with archive mode as it uses A LOT OF RAM !--compress-level=9
: Uses the highest level of compression to save bandwidth.--exclude='*.tmp'
: Excludes all temporary files from the transfer to avoid sending unnecessary data.--bwlimit=1000
: Limits bandwidth usage to 1000 KB/s to avoid saturating your connection.--log-file=rsync.log
: Creates a log file to track transfer details.-e "ssh -p 52333 -oCiphers=aes256-gcm@openssh.com"
: Specifies using SSH for connection, on a custom port (52333) and with a specific cipher for improved security.