Rsync is a great file and folder-coping tool for Linux systems. It can also synchronize files and directories between two systems or on the same host.
Rsync is a significant file copying and file synchronization tool for Linux systems. Not too sure if there are Windows versions or similar software that works for Windows systems.
With Rsync, users can copy files and folders from one location to another on the same host or via SSH protocol on different hosts. When you use Rsync to copy or synchronize directories, it will copy and synchronize file links, ownership, groups, and permissions.
It’s an excellent tool for copying files and directories between two networked systems.
This brief tutorial shows you some options to copy files with Rsync tools. After reading this tutorial, you’ll be able to install and use Rsync to copy files and folders to another location.
Installing Rsync on Ubuntu
Before you can use Rsync on Ubuntu, you must first install it. To install the software tool on Ubuntu, run the commands below.
sudo apt-get update sudo apt-get -y install rsync
Copying files and folders using Rsync
After installing Rsync, use the help command to find all options that are available to Rsync. For example, to see the help file, run the commands below.
The format for Rsync is as follows. If you don’t follow the command format shown below, Rsync may not be able to copy and synchronize content as intended.
rsync option source_location destination_location
For example, to copy a file from /var/www/html/file to /var/log/test, you will run the commands below
rsync options /var/www/html/file /var/log/test
The command options for Rsync are listed below:
-a, --archive archive mode -v, --verbose increase verbosity -z, --compress compress file data during the transfer -t, --times preserve modification times -p, --perms preserve permissions -h, --human-readable output numbers in a more human-readable format -l, --links copy symlinks as symlinks -e, --rsh=COMMAND specify the remote shell to use --numeric-ids don't map uid/gid values by user/group name --delete delete extraneous files from dest dirs
That’s the basics of Rsync.
Copying the directory /tmp/local/public to /var/www/html, you’ll run the commands below:
rsync -avzh /var/local/public/ /var/www/html
This copies all the content in /var/local/public to /var/www/html
To copy local content to a remote host, you’ll use the format as follows below:
rync -avzh /var/local/content email@example.com:/var/remote/content
Replace admin with the actual account name on the remote system.
So, you can see how powerful and easy-to-use Rsync is. Use Rsync to copy or synchronize stuff between two separate directories on the local or remote host.
Please contribute to this post if you have other tools to share with our audience.