Both sides previous revision Previous revision Next revision | Previous revision |
home_server:home_server_setup:other_services:rsync [2023-05-28 Sun wk21 10:29] – [An Important Notes] baumkp | home_server:home_server_setup:other_services:rsync [2023-12-26 Tue wk52 11:38] (current) – baumkp |
---|
{{tag>rsync backup linux debian ubuntu rsnapshot}} | {{tag>rsync backup linux debian rsnapshot}} |
======Rsync====== | ======Rsync====== |
These are my rsync notes. I also used to use rsnapshot, however I was unhappy with the performance of this application and moved to restic. The original rsnapshot notes have been rolled up and moved to the bottom of this page. | These are my rsync notes. I also used to use rsnapshot, however I was unhappy with the performance of this application and moved to restic. The original rsnapshot notes have been rolled up and moved to the bottom of this page. |
| |
| |
====An Important Notes==== | ====Main rsync command usage summary==== |
| |
A trailing slash (/) at the end of the first argument in the rsync command: ''rsync -a dir1/ dir2'', mean “the contents of dir1”. The alternative, without the trailing slash, would place dir1, including the directory, within dir2. This would create a hierarchy that looks like: ~/dir2/dir1/[files] | A trailing slash (/) at the end of the first argument in the rsync command: ''rsync -a dir1/ dir2'', mean “the contents of dir1”. The alternative, without the trailing slash, would place dir1, including the directory, within dir2. This would create a hierarchy that looks like: ~/dir2/dir1/[files] |
*''-h''' human readable file sizes | *''-h''' human readable file sizes |
*''-v'' increase output verbosity | *''-v'' increase output verbosity |
*''-z'' compress files on transfer | *''-z'' compress files on transfer, note does not necessarily increase transfer speeds, dependent on file types transferred and CPU speeds |
| |
Always double-check your arguments before executing an rsync command. Rsync provides a method for doing this by passing the ''-n'' or ''%%-–%%dry-run'' options. The -v flag (for verbose) is also necessary to get the appropriate output: | Always double-check your arguments before executing an rsync command. Rsync provides a method for doing this by passing the ''-n'' or ''%%-–%%dry-run'' options. The -v flag (for verbose) is also necessary to get the appropriate output: |
| |
====rsync daemon==== | ====rsync daemon==== |
| ++++tl;dr;| |
rsync can be installed as a daemon on a computer instance | rsync can be installed as a daemon on a computer instance |
| |
| |
''sudo systemctl status rsync.service'' [status, start, stop, restart, reload, disable, enable] | ''sudo systemctl status rsync.service'' [status, start, stop, restart, reload, disable, enable] |
| ++++ |
| |
| ====Notes on Compression option==== |
====Compression option -z can slow down file transfer.==== | Compression option -z can slow down file transfer notes as well as some examples I used |
| ++++tl;dr;| |
''export RSYNC_SKIP_COMPRESS=3fr/3g2/3gp/3gpp/7z/aac/ace/amr/apk/appx/appxbundle/arc/arj/arw/asf/avi/bz2/cab/cr2/crypt[5678]/dat/dcr/deb/dmg/drc/ear/erf/flac/flv/gif/gpg/gz/iiq/iso/jar/jp2/jpeg/jpg/k25/kdc/lz/lzma/lzo/m4[apv]/mef/mkv/mos/mov/mp[34]/mpeg/mp[gv]/msi/nef/oga/ogg/ogv/opus/orf/pef/png/qt/rar/rpm/rw2/rzip/s7z/sfx/sr2/srf/svgz/t[gb]z/tlz/txz/vob/wim/wma/wmv/xz/zip'' | ''export RSYNC_SKIP_COMPRESS=3fr/3g2/3gp/3gpp/7z/aac/ace/amr/apk/appx/appxbundle/arc/arj/arw/asf/avi/bz2/cab/cr2/crypt[5678]/dat/dcr/deb/dmg/drc/ear/erf/flac/flv/gif/gpg/gz/iiq/iso/jar/jp2/jpeg/jpg/k25/kdc/lz/lzma/lzo/m4[apv]/mef/mkv/mos/mov/mp[34]/mpeg/mp[gv]/msi/nef/oga/ogg/ogv/opus/orf/pef/png/qt/rar/rpm/rw2/rzip/s7z/sfx/sr2/srf/svgz/t[gb]z/tlz/txz/vob/wim/wma/wmv/xz/zip'' |
| |
| |
''sudo rsync x -a -Puh /home/shared/temp/ baumkp@192.168.1.10::all/home/shared/html_kptree.net %%--%%exclude=.Trash* >tmp.txt'' | ''sudo rsync x -a -Puh /home/shared/temp/ baumkp@192.168.1.10::all/home/shared/html_kptree.net %%--%%exclude=.Trash* >tmp.txt'' |
| ++++ |
| |
| ====My web page copy bash batch==== |
| ''sudo vim Myscripts/rsync_shared.sh'' or to run ''sudo bash Myscripts/rsync_shared.sh'' |
| |
| #Note this is a local only script and takes no additional batch inputs when run! |
| ++++code| |
| <code bash> |
| #!/bin/bash |
| wwwpath='/home/shared/www/html' |
| workpath='/home/shared/html_kptree.net/' |
| cmd="rsync -ptoguv --chown=root:www-data --chmod=a+rwx,g+rwx,o-wx" |
| $cmd ${workpath}/styles.css ${wwwpath} |
| $cmd ${workpath}/w3.css ${wwwpath} |
| $cmd ${workpath}/index.html ${wwwpath} |
| $cmd ${workpath}/email_server_w3.html ${wwwpath} |
| </code> |
| ++++ |
====some rsync flag definitions==== | ====some rsync flag definitions==== |
| Simply type ''rsync'' at terminal to see a complete list |
^Flag Short^ Flag Long ^Description^ | ^Flag Short^ Flag Long ^Description^ |
|''-z''| ''%%--%%compress'' |compress file data during the transfer| | |''-z''| ''%%--%%compress'' |compress file data during the transfer| |
* * preservation of hard links is important when moving across rsnapshots backups between disks. | * * preservation of hard links is important when moving across rsnapshots backups between disks. |
| |
My web page copy bash batch: | |
''sudo vim Myscripts/rsync_shared.sh'' or to run ''sudo bash Myscripts/rsync_shared.sh'' | |
| |
#Note this is a local only script and takes no additional batch inputs when run! | |
<code bash> | |
#!/bin/bash | |
wwwpath='/home/shared/www/html' | |
workpath='/home/shared/html_kptree.net/' | |
cmd="rsync -ptoguv --chown=root:www-data --chmod=a+rwx,g+rwx,o-wx" | |
$cmd ${workpath}/styles.css ${wwwpath} | |
$cmd ${workpath}/w3.css ${wwwpath} | |
$cmd ${workpath}/index.html ${wwwpath} | |
$cmd ${workpath}/email_server_w3.html ${wwwpath} | |
</code> | |
| |
---- | ---- |