home_server:home_server_setup:other_services:rsync

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
home_server:home_server_setup:other_services:rsync [2023-05-28 Sun wk21 10:21] – [Rsync] baumkphome_server:home_server_setup:other_services:rsync [2023-12-26 Tue wk52 11:38] (current) baumkp
Line 1: Line 1:
-{{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 rsyncsnapshot+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.
  
  
Line 7: Line 7:
  
  
-====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]
Line 15: Line 15:
 Where  Where 
   *''-a'' is the flag for archive.  Keeps original dates and permissions on copy and also recurses, copied sub-directories and content.   *''-a'' is the flag for archive.  Keeps original dates and permissions on copy and also recurses, copied sub-directories and content.
 +  *''-u'' only copies source files where they are newer than destination files (based upon file modification dates)
 +  *''--delete'' deletes files on the destination where they are not on the source.  **//Use with care!//**
 +  *''-n'' is for dry run, no changes are made, but proposed output is seen
 +  *''-P'' keeps partially copies files and reports progress
 +  *''-h''' human readable file sizes
 +  *''-v'' increase output verbosity
 +  *''-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
  
Line 46: Line 54:
  
 ''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''
  
Line 70: Line 80:
  
 ''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|
Line 102: Line 130:
   * * 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> 
  
 ---- ----
  • /app/www/public/data/attic/home_server/home_server_setup/other_services/rsync.1685240474.txt.gz
  • Last modified: 2023-05-28 Sun wk21 10:21
  • by baumkp