Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to one-way sync using rsync on Ubuntu

📅 2013-Jan-25 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

rsync is an excellent program to perform one-way sync between directories.

If both the source and destination directories are on local storage:

$ rsync -av /home/joe/from-dir /media/backup/to-dir

To make the destination a strict mirror copy, thus deleting any extra files it may have:

$ rsync -av --delete /home/joe/from-dir /media/backup/to-dir

If one or both of the source and destination is not on local storage, then rsync can be asked to use compression to save transfer time:

$ rsync -avz /home/joe/from-dir /mars/great-valley/to-dir

Tried with: rsync 3.0.9 and Ubuntu 12.04.1 LTS