How To Use Rsync to Sync Local and Remote Directories on Linux

How To Use Rsync to Sync Local and Remote Directories on Linux

Rsync (Remote Sync) is a commonly used tool to transfer and synchronize files and directories across computer system.

By using rsync command, you can easily transfer file on remote server or can take backup on your local system remotely.

It was first announced on 19 june 1996 written by Andrew Tridgell and Paul Mackerras.

It has becoma a powerful Linux utility because of its flexibility and speed.

Some features of Rsync command
  • Support for copying devices, links, owners, groups and permissions.
  • Does not require any special root privileges to install.
  • Easily transfer files to or from a remote system.
  • rsync use remote update protocol that transfer only differences in the file which means first time it transfer complete files from source to destination but later once you made any changes in the file then it transfer the changed blocks to the destination that's the reason it is faster than scp.
  • Mostly used for backups and mirroring.
  • Rsync does not consume high bandwidth because it use compression method while transferring data.
Rsync Syntax :
# rsync options source destination

Some common options used with rsync commands

  • -v: for verbose.
  • -r: for recursive that is used to sync directory.
  • -a: for archive mode that is used to sync recursively and preserves symbolic links, modification times, group, owner, and permissions.
  • -z: for adding compression.
  • -u: for update
  • -b: for backup
  • -h: for human-readable
Install rsync in your Linux machine (Debian based systems)

You can install rsync package in your linux system by running following line of command :

# apt-get install rsync
1. Copy/Sync a File on a Local System

In this example, we will sync a single file from one location to other location on local machine.

I have a file name xyz.tar and want to sync to /tmp/backups/ folder.

# rsync -zvh xyz.tar /tmp/backups/

By running above command, you will see if destination directory is not exists then it will create directory automatically and then sync file.

2. Copy/Sync a Directory on a Local System

In this example, we will sync all files from one directory to other directory in same local machine.

I have directory /var/www/app that contains some files that will be sync to /var/www/app1 directory by running following command.

# rsync -avzh /var/www/app /var/www/app1
3. Copy/Sync a Directory from Local to Remote Server

In this example, we will copy all files of a directory from local machine to directory of remote machine.

Suppose you have a project in /var/www/app directory and you want to copy all files within this directory to remote machine then you can go with following command :

$ rsync -avz /var/www/app username@remote-host:/home/
4. Copy/Sync a Directory from Remote to Local Server

In this example, you will see how to sync a remote directory to local directory by running following command :

# rsync -avzh username@remote-host:/home/xyz/ /var/www/app

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
hatay escort nevsehir escort nigde escort kirikkale escort batman escort osmaniye escort kirklareli escort tokat escort rize escort adiyaman escort gumushane escort batman escort
porno izle
cialis satış cialis fiyat cialis 20 mg cialis 100 mg cialis 5 mg fiyat
sohbet okey oyna
ankara escort marmaris escort bursa escort mersin escort antalya escort izmir escort samsun escort bodrum escort çeşme escort kuşadası escort adana escort eskişehir escort gaziantep escort esenyurt escort pendik escort tuzla escort fatih escort ümraniye escort mecidiyeköy escort kartal escort bahçelievler escort bahçeşehir escort ataşehir escort bakırköy escort nişantaşı escort avcılar escort büyükçekmece escort kurtkoy escort konya escort beşiktaş escort taksim escort beylikdüzü escort malatya escort sakarya escort şişli escort maltepe escort kadıköy escort ataköy escort bostancı escort şirinevler escort bağcılar escort üsküdar escort etiler escort başaksehir escort ortaköy escort kağıthane escort sultangazi escort halkalı escort çekmeköy escort şaşkınbakkal escort mamak escort sincan escort keçiören escort çankaya escort beypazarı escort akyurt escort pursaklar escort kahramankazan escort göztepe escort alsancak escort bornova escort buca escort karabaglar escort karşıyaka escort konak escort narlıdere escort izmit escort başiskele escort kandira escort körfez escort karamürsel escort dilovası escort gölcük escort gebze escort kocaeli escort kayseri escort elazığ escort denizli escort diyarbakir escort adana escort ankara escort izmir escort antalya escort gaziantep escort kayseri escort konya escort mersin escort denizli escort kocaeli escort diyarbakır escort