/home/posts/intro-to-rsync

Intro to Rsync

Published on

#Introduction

rsync - a fast, versatile, remote (and local) file-copying tool
rsync man page

As the man page suggests, rsync is a useful tool if you’re tired of cp-ing files around servers and managing the disastrous permissions aftermath. It has the ability to manage permissions, compress on-the-fly, and doesn’t waste time copying things that already exist in the destination.

#Rsync is Smart

Let’s say you have two folders, folder1 and folder2. These folders contain a very large amount of data, and right now they are the exact same. But let’s say you make a small change to folder1, like maybe adding a small file, or fixing a typo somewhere.

Without rsync, to ensure folder2 still contains an accurate copy, you have a couple options:

Rsync is smart in that it only copies changes to your files. If we added one-small-file.txt to folder1 and ran rsync, it would only add one-small-file.txt to folder2 and call it a day- no need to re-copy the existing accurate files.

#Example Use Case: Copying Music

I run an Airsonic music server, which holds the “master copy” of some music I listen to. However, I prefer to keep local copies of this music on some of my machines, and so I find myself constantly having to keep all versions of this music the same across all my machines and server.

What about Git? Git is a version control system that would appear to solve this problem of concurrency; however, git works poorly for this use case.

With a single rsync command on each machine, I can pull down changes to the music folder to my local copy. This way, the copy on the server is the only one I have to manage.

bash

rsync --delete --recursive --compress --verbose user@domain.com:/remote/music/ /local/music/

#Conclusion

Rsync is a versatile tool, and has a ton of capabilities I didn’t cover in this introduction. man rsync covers these and more.

Meet the Author

John Allbritten

Nashville, TN

I love learning new technologies, and I have a passion for open source. As I learn things, my notes turn into articles to share.

Keep Reading