FactorPad
Faster Learning Tutorials

Linux rsync command summary with examples

rsync allows you to synchronize (backup) file systems.
  1. Purpose - Learn what rsync is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with rsync.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, November 7, 2016
Updated: August 5, 2018
In this tutorial, 74 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / rsync command


The Linux rsync command

Beginner

Learn to securely backup file systems at the Linux command line.

Video Tutorial

Linux rsync command summary with examples (3:24)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our seventy-fourth word, or command to memorize is rsync from our category Files.

rsync allows you to synchronize (backup) file systems.

Recall from the last block of six videos, we've been compressing files and making archives, now we'll create backups of those archives, often called mirrors, on other disk drives, and we could even do it remotely (ie, online backup).

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The rsync command has over 50 options and the arguments include the source followed by the destination.

Like most commands, help is available with double-dash --help. Option -a creates an archive, meaning sub-directories too. And -v, like with other commands, gives a progress report.

So why is rsync an important command? Well, rsync not only saves time when making backups versus plain copying, but also syncs only updated files, saving bandwidth, plus it can also be scheduled and automated. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Because this is normally an administrator function, with rsync, I'll just show the basics. Let's do a directory listing.

$ ls stuff video23.txt video34.txt video40.txt video57.txt video69b.txt video72.zip video05.txt video24.txt video35.txt video44.txt video64.txt video69b.txt.gz video73a.txt video11.txt video26.txt video36.txt video48a.txt video65.txt video70.txt video73.tar video16.txt video27.txt video37.txt video48b.txt video67.txt video70.txt.bz2 video19.txt video31.txt video38a.txt video54.txt video68a.txt video71.txt video20.txt video32.txt video38b.txt video55.txt video68b.txt video71.txt.xz video21.txt video33.txt video38c.txt video56.txt video69a.txt video72

If you haven't been with us from the start, we have been busy.

So, now we'll back this up, and in the home directory create a target which imagine could be on another file system remotely (through ssh for example) and call it, cleverly, backup.

$ mkdir ../backup

Next, let's do an rsync with with options -av, the source ../linux, like this, and the destination ../backup, like this, and it'll put a backup of the whole directory of files.

$ rsync -av ../linux ../backup sending incremental file list linux/ linux/video05.txt linux/video11.txt linux/video16.txt linux/video19.txt linux/video20.txt linux/video21.txt -> ../ridiculouslylongfilename.txt linux/video23.txt linux/video24.txt linux/video26.txt linux/video27.txt linux/video31.txt linux/video32.txt linux/video33.txt linux/video34.txt linux/video35.txt linux/video36.txt linux/video37.txt linux/video38a.txt linux/video38b.txt linux/video38c.txt linux/video40.txt linux/video44.txt linux/video48a.txt linux/video48b.txt linux/video54.txt linux/video55.txt linux/video56.txt linux/video57.txt linux/video64.txt linux/video65.txt linux/video67.txt linux/video68a.txt linux/video68b.txt linux/video69a.txt linux/video69b.txt linux/video69b.txt.gz linux/video70.txt linux/video70.txt.bz2 linux/video71.txt linux/video71.txt.xz linux/video72.zip linux/video72.tar linux/video73a.txt linux/stuff/ linux/video72/ linux/video72/video72a.txt linux/video72/video72b.txt sent 555,686 bytes received 875 bytes 1,113,122.00 bytes/sec total size is 552,577 speedup is 0.99

And then last, let's verify with an ls on the directory ../backup/linux and make sure everything showed up.

$ ls ../backup/linux stuff video23.txt video34.txt video40.txt video57.txt video69b.txt video72.zip video05.txt video24.txt video35.txt video44.txt video64.txt video69b.txt.gz video73a.txt video11.txt video26.txt video36.txt video48a.txt video65.txt video70.txt video73.tar video16.txt video27.txt video37.txt video48b.txt video67.txt video70.txt.bz2 video19.txt video31.txt video38a.txt video54.txt video68a.txt video71.txt video20.txt video32.txt video38b.txt video55.txt video68b.txt video71.txt.xz video21.txt video33.txt video38c.txt video56.txt video69a.txt video72

A Final Tip

Okay now you know how to use rsync. And you know the syntax for commands, options and arguments.

One last tip about the rsync command. So just like the feeling of (backup) safety on Windows, or Time Machine on Mac, it's nice to know data is safe and rsync provides that for you.

Okay, thanks for visiting today. I hope this was a helpful introduction to the rsync command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

If you love learning like we do, then we'd love to have you join us on YouTube, subscribe here.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the tar command, hit Back.
  • To move on to the topic of Users with a tutorial on chmod, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / rsync command



 
 
Keywords:
linux rsync command
rsync linux
rsync example
remote backup
online backup
rsync backup
rsync ssh
rsync tutorial
man rsync
linux backup
online data storage
best online backup
backup server
server backup software
rsync over ssh
rsync examples
rsync options