# rSync

====================================================================================

#### What is rSync?

rSync is a file transfer command that can be used for both local and remote transfers.

<p class="callout danger">Remember to be careful with rSync - it's a synchronisation command and can overwrite files.  
  
example:  
  
I have 2 directories:  
/:  
directory1:  
 |\_&gt;file1  
directory2:  
 |\_&gt; file1  
 |\_&gt; file2  
If I run `rsync directory1 directory2`, then file2 would be removed, and file1 would be synced.  
</p>

**<span class="TextRun SCXO41186676 BCX0" data-contrast="none" lang="EN-US" xml:lang="EN-US"><span class="NormalTextRun SCXO41186676 BCX0">-----------------------------------------------------------------------------------------------------------------------------------------------</span></span>**

#### rSync command syntax

rsync \[option\] \[[user@host](mailto:user@host)\]

**Basic local file transfer**

```
rsync /sourcefile /destinationfile
```

**Basic remote file transfer:**

```
rsync /sourcefile user@IP_IP_IP_IP:destination/location/on/remote/server
```

**rSync Tunelling (secure rsync over SSH)**

```
rsync -e ssh /sourcefile user@IP_IP_IP_IP:destination/location/on/remote/server
```

##### **flags:**

<table border="1" id="bkmrk--a-archive--z-gzip-c" style="border-collapse: collapse; width: 100%; height: 247.75px;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">-a</td><td style="height: 29.7969px;">archive</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">-z</td><td style="height: 29.7969px;">gzip compression</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">-u </td><td style="height: 29.7969px;">skip existing files at destination</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">-r </td><td style="height: 29.7969px;">recursive</td></tr><tr style="height: 35.3906px;"><td style="height: 35.3906px;">-P</td><td style="height: 35.3906px;">show progress of transfer

</td></tr><tr style="height: 57.7812px;"><td style="height: 57.7812px;">--exclude=</td><td style="height: 57.7812px;">specify files to ignore (ie "\*.log") (needs to be paired with --include). Appended to command prior to source file specification.

</td></tr><tr style="height: 35.3906px;"><td style="height: 35.3906px;">--include=</td><td style="height: 35.3906px;">(only needed if using --exclude) If you're excluding files from an rsync transfer, you'll need to add --include="\*". Appended to command prior to source file specification.

</td></tr><tr><td>--dry-run</td><td>Test run of rSync to display the changes that would be made. No file synchronisation is performed with this option enabled. Appended to end of command.

</td></tr></tbody></table>

====================================================================================