rsync
2013-03-21.
Category & Tags:
Soft&Skills
Soft&Skills
Usage:
# general usage:
rsync -avhuzP /path/to/src_folder/ username@serverIp:/home/username/path/to/dest_folder/
# other usages:
alias rsyncBackupCompareAttr='rsync -avhuz --progress --delete --log-file=rsyncBackupLog.txt'
alias rsyncBackupIgnoreAttr='rsync -avhuz --no-perms --no-owner --no-group --progress --delete --log-file=rsyncBackupLog-$(date -d "today" +"%Y%m%d_%H%M%S").log.txt'
alias rsyncBackupProgressIgnoreAttr='rsync -ahuz -e 'ssh -p <remote_port>' --exclude "@eaDir" --exclude ".SynologyWorkingDirectory" --exclude ".stfolder" --info=progress2 --no-perms --no-owner --no-group --delete --log-file=rsyncBackupLog-$(date -d "today" +"%Y%m%d_%H%M%S").log.txt'
options:
-a
: archive mode is-rlptgoD
(no -A,-X,-U,-N,-H).-v
: ==--verbose
.-h
: human-readable.-u
: transfer only if src has (newer timestamp) or (equal timestamp & different size).-z
: ==--compress
during transfer.-P
: ==--partial --progress
.--partial
: keep partially transfered files in dest (will overwrite/delete.&.re-transfer by default).-e
: for params of ssh, e.g. tcp port number.--info=progress2
:- shows:
- 1 overall transferred size;
- 2 overall size-wise progress (depends on size of “detected” files, increases during transfer as detecting in progress);
- 3 speed;
- 4 remaining time which varies with speed & detected files (switch to elapsed time for 1 sec. when xfr file counter increases);
- 5.1 xfr: file counter;
- 5.2 ir-chk: nr. of files currently in queue to be checked / nr. of files recursively detected (change to “to-chk” when file detection is done).
- note: this options is since v3.1.0
- warn: both
-v
and-p
overwrite this option - ref: stackOverflow, stackExchange
- shows:
“–info=progress2” e.g.:
OBS:
rsync folderA folderB
will cp folderA into,under folderB.
rsync folderA/ folderB/
will cp folderA’s content into folderB.
Thus, /
s after both folderX
are mandatory.
Becareful with -u
: it will ignore the dest file with newer timestamp.