19.27 Rsync Remote Files
20210313
Rsync can be used to synchronise files locally or remotely.
Below we illustrate typical archival (-a
or --archive
)
synchronisations, printing a log of the activity (-v
or
--verbose
), compressing files during the transfer (-z
or
--compress
), with numbers in a human-readable format (-h
or
--human-readable
).
The long version, synchronising all local html files to a remote host (togaware.com):
rync --archive --verbose --compress --human-readable *.html togaware.com:site/
The short version of the same synchronisation:
rync -avzh *.html togaware.com:site/
To also update permissions use --chmod=
. Here we ensure all the
remote files are readable by everyone.
rync -avzh --chmod=a+r *.html togaware.com:site/
To ignore any file or directory named cache we use --exclude
:
$ rsync -avzh --exclude 'cache' local/ togaware.com:BACKUP/local/
To ignore backup files identified as having a trailing tilde, for example:
$ rsync -avzh --exclude '*~' local/ togaware.com:BACKUP/local/
To remove any remote files that are not in the current source directory
use --delete
:
$ rsync -avzh --delete local/ togaware.com:BACKUP/local/
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0
