Check this Out!Visit our social network pages for recent updates!

Students question – How to Use Rsync on Ubuntu?

Rsync is a great files / folders coping tool for Linux systems. It can also be used to synchronize files and directories between two systems or on the same host. Hos can new students or new users use Rsync?

Rsync is a great and file copying and file synchronization tool for Linux systems. Not too sure if there are Windows version 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 a great tool to use to copy files and directories between two networked systems.

This brief tutorial shows you some of the options one can use with Rsync tools to copy files. After reading this tutorial, you’ll be able to install and use Rsync to copy files and folders to another locations.

Installing Rsync on Ubuntu

Before you can use Rsync on Ubuntu, you must fist 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 folder using Rsync

After installing Rsync, use the help command to find all options that are available to Rsync. To see the help file, run the commands below.

man rsync

The format for Rsync is as followed. 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 list 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 a local content to a remote host, you’ll use the format as followed below:

rync -avzh /var/local/content     admin@1921.168.241.2:/var/remote/content

Replace admin with the actual account name on the remote system.

So, you can see how powerful and easy-to-use is Rsync. When you want to copy or synchronize stuff between two separate directories on the local or remote host, use Rsync.

Please contribute to this post if you have other tools share with our audience.

Enjoy!

Leave a Reply