rsync commands

Wed, 14 May 2025 02:02:09 GMT

rsync is a useful tool for copying files to a remote machine using ssh.
simple command to backup a directory is
rsync -a ~/dir1 username@remote_host:destination_directory
if the username is the same on both systems you can omit the username@
if you omit the destination after the : then files are copied to the users home folder.

comand line options
-a archive mode which preserves file permissions
-z will compress the file during transfer to make the transfer faster
-P will show progress and also allows partial transfer so that files that havent been changed won't have to be transferred again.
-an --delete forces rsync to delete the files on the destination before copying the source file. this is not the default behavior of rsync
-v is for verbose output giving information about the transfer as it is happening.
-h gives human readable output on files sizes etc.

Give rsync a try it is quite useful