Rsync [remote sync]

(λx.x)eranga
Effectz.AI
Published in
2 min readFeb 21, 2016

About Rsync

Rsync[remote sync]is a tool that provides fast incremental file transfer. It is a powerful backup and copy utility. Rsync can be used to copy/transfer files in locally as well remotely(over the network)

Rsync syntax

Backup files over ssh

Rsync can be used as a backup tool. Consider the scenario

I want to daily backup a remote machine’s directory/file . Assume my local machine is (10.4.1.100) and remote machine is (10.4.1.200)

Following are the steps to do that.

1. Generate ssh keys

You need to generate ssh keys for both your local and remote machines. Following is the way to gengerate ssh keys.

This command will generates public/private key pair in ~/.ssh directory. We have used empty passphrase(-P “”) is here.

2. SSH config

You need to connect to remote host via ssh without password prompt. To do that you need to add the public key(~/.ssh/id_rsa.pub) of your local machine to ~/.ssh/authorized_keys file in remote machine.

Now you can connect to remote host without password prompt since local machine can be authorized with public key.

3. Setup rsync

Following is the rsync command to backup remote directory to my local machine.

4. Rsync with cron job

Since I need to take periodic/daily backup of the remote directory, I can set up a cronjob to run previous rsync command. To do that add following entry to your crontab file.

--

--