Skip to content

Latest commit

 

History

History
221 lines (206 loc) · 20.8 KB

cix-rsync.org

File metadata and controls

221 lines (206 loc) · 20.8 KB

rsync

|≣|

AuthorAndrew Tridgell,
Paul Mackerras
Maintainer(s)
Released1996
Sourcersync.git
Manrsync.1
Homepagersync.web

rsync uses a reliable algorithm to bring remote and host files into sync very quickly. rsync is fast because it just sends the differences in the files over the network instead of sending the complete files. rsync is often used as a very powerful mirroring process or just as a more capable replacement for the rcp command. A technical report which describes the rsync algorithm is included in this package.


Receipts

rsync

rsync::options

OPTTYPE--V++VDESC
--address=<address>bind address for outgoing socket to daemon
--appendappend data onto shorter files
--append-verify–append w/old data in file checksum
--backup-dir=DIRmake backups into hierarchy based in DIR
--blocking-iouse blocking I/O for the remote shell
--bwlimit=<rate>limit socket I/O bandwidth
--checksum-seed=<=num>set block/file checksum seed (advanced)
--chmod=CHMODaffect file and/or directory permissions
--chown=USER:GROUPsimple username/groupname mapping
--compare-dest=DIRalso compare received files relative to DIR
--compress-level=NUMexplicitly set compression level
--contimeout=SECONDSset daemon connection timeout in seconds
--copy-dest=DIR… and include copies of unchanged files
--copy-devicescopy device contents as regular file
--copy-unsafe-linksonly “unsafe” symlinks are transformed
--debug=FLAGSfine-grained debug verbosity
--delan alias for –delete-during
--delay-updatesput all updated files into place at end
--deletedelete extraneous files from dest dirs
--delete-afterreceiver deletes after transfer, not during
--delete-beforereceiver deletes before xfer, not during
--delete-delayfind deletions during, delete after
--delete-duringreceiver deletes during the transfer
--delete-excludedalso delete excluded files from dest dirs
--delete-missing-argsdelete missing source args from destination
--devicespreserve device files (super-user only)
--exclude-from=FILEread exclude patterns from FILE
--exclude=PATTERNexclude files matching PATTERN
--existingskip creating new files on receiver
--fake-superstore/recover privileged attrs using xattrs
--files-from=FILEread list of source-file names from FILE
--forceforce deletion of dirs even if not empty
--groupmap=STRINGcustom groupname mapping
--iconv=CONVERT_SPECrequest charset conversion of filenames
--ignore-errorsdelete even if there are I/O errors
--ignore-existingskip updating files that exist on receiver
--ignore-missing-argsignore missing source args without error
--include-from=FILEread include patterns from FILE
--include=PATTERNdon’t exclude files matching PATTERN
--info=FLAGSfine-grained informational verbosity
--inplaceupdate destination files in-place
--link-dest=DIRhardlink to files in DIR when unchanged
--list-onlylist the files instead of copying them
--log-file-format=FMTlog updates using the specified FMT
--log-file=FILElog what we’re doing to the specified FILE
--max-delete=NUMdon’t delete more than NUM files
--max-size=SIZEdon’t transfer any file larger than SIZE
--min-size=SIZEdon’t transfer any file smaller than SIZE
--modify-window=NUMcompare mod-times with reduced accuracy
--msgs2stderrspecial output handling for debugging
--munge-linksmunge symlinks to make them safer
--no-OPTIONturn off an implied OPTION (e.g. –no-D)
--no-implied-dirsdon’t send implied dirs with –relative
--no-motdsuppress daemon-mode MOTD (see caveat)
--numeric-idsdon’t map uid/gid values by user/group name
--only-write-batch=FILElike –write-batch but w/o updating dest
--out-format=FORMAToutput updates using the specified FORMAT
--outbuf=N,L,Bset out buffering to None, Line, or Block
--partialkeep partially transferred files
--partial-dir=DIRput a partially transferred file into DIR
--password-file=FILEread daemon-access password from FILE
--port=PORTspecify double-colon alternate port number
--preallocateallocate dest files before writing
--progressshow progress during transfer
--protocol=NUMforce an older protocol version to be used
--read-batch=FILEread a batched update from FILE
--remove-source-filessender removes synchronized files (non-dir)
--rsync-path=PROGRAMspecify the rsync to run on remote machine
--safe-linksignore symlinks that point outside the tree
--size-onlyskip files that match in size
--skip-compress=LISTskip compressing files with suffix in LIST
--sockopts=OPTIONSspecify custom TCP options
--specialspreserve special files
--statsgive some file-transfer stats
--suffix=SUFFIXbackup suffix (default ~ w/o –backup-dir)
--superreceiver attempts super-user activities
--timeout=SECONDSset I/O timeout in seconds
--usermap=STRINGcustom username mapping
--versionprint version number
--write-batch=FILEwrite a batched update to FILE
-0, --from0all *from/filter files are delimited by 0s
-4, --ipv4prefer IPv4
-6, --ipv6prefer IPv6
-8, --8-bit-outputleave high-bit chars unescaped in output
-A, --aclspreserve ACLs (implies -p)
-B, --block-size=SIZEforce a fixed checksum block-size
-C, --cvs-excludeauto-ignore files in the same way CVS does
-Dsame as –devices –specials
-E, --executabilitypreserve executability
-Fsame as –filter=’dir-merge /.rsync-filter’ repeated: –filter=’- .rsync-filter’
-H, --hard-linkspreserve hard links
-I, --ignore-timesdon’t skip files that match size and time
-J, --omit-link-timesomit symlinks from –times
-K, --keep-dirlinkstreat symlinked dir on receiver as dir
-L, --copy-linkstransform symlink into referent file/dir
-M, --remote-option=OPTIONsend OPTION to the remote side only
-O, --omit-dir-timesomit directories from –times
-Psame as –partial –progress
-R, --relativeuse relative path names
-S, --sparsehandle sparse files efficiently
-T, --temp-dir=DIRcreate temporary files in directory DIR
-W, --whole-filecopy files whole (w/o delta-xfer algorithm)
-X, --xattrspreserve extended attributes
-a, --archivearchive mode; equals -rlptgoD (no -H,-A,-X)
-b, --backupmake backups (see –suffix & –backup-dir)
-c, --checksumskip based on checksum, not mod-time & size
-d, --dirstransfer directories without recursing
-e, --rsh=COMMANDspecify the remote shell to use
-f, --filter=RULEadd a file-filtering RULE
-g, --grouppreserve group
-h --helpshow this help (see below for -h comment)
-h, --human-readableoutput numbers in a human-readable format
-i, --itemize-changesoutput a change-summary for all updates
-k, --copy-dirlinkstransform symlink to dir into referent dir
-l, --linkscopy symlinks as symlinks
-m, --prune-empty-dirsprune empty directory chains from file-list
-n, --dry-runperform a trial run with no changes made
-o, --ownerpreserve owner (super-user only)
-p, --permspreserve permissions
-q, --quietsuppress non-error messages
-r, --recursiverecurse into directories
-s, --protect-argsno space-splitting; wildcard chars only
-t, --timespreserve modification times
-u, --updateskip files that are newer on the receiver
-v, --verboseincrease verbosity
-x, --one-file-systemdon’t cross filesystem boundaries
-y, --fuzzyfind similar file for basis if no dest file
-z, --compresscompress file data during the transfer

rsync::examples

rsync-161128234019

Resume rsync after broken connection:

#!/usr/bin/env bash

FILE_TO_SEND="send_me.there"
HOST_NAME="waiting.for.me"
USER_NAME="are_you"

while true; do
    rsync -avz --append "$FILE_TO_SEND" "$USER_NAME"@"$HOST_NAME"
    [[ "$?" = "0" ]] && break
    echo "File is not tranfared, resume."
done

echo while

rsync-161210234525

multi-threaded rsync on a splitted file you can use tar to create a consolidated file and split it after that and use key authentication:

#!/usr/bin/env bash

THREADS="$(grep -c processor /proc/cpuinfo)"
CHUNK="10M"
SUFF="splitted_file_"
FNAME="test_file"

SRC_PATH="$HOME"
SRC_SHA256="$(sha256sum ${SRC_PATH}/test_file)"
# Having key authentication can ease the rsync process
DST="misa"
DST_PATH="${DST}:~/"

echo "$SRC_SHA256"
split --bytes="$CHUNK" "${SRC_PATH}/${FNAME}" "${SRC_PATH}/${SUFF}"

find "$SRC_PATH" -maxdepth 1 -name "${SUFF}*" -print0 \
    | xargs -0 -n1 -P"$THREADS" -I% \
            rsync --archive --compress "%" "$DST_PATH"

# Consolidate chunks and hash-check destination integrity
ssh "$DST" "cat ${SUFF}* > ${FNAME} && sha256sum test_file && rm ${SUFF}*"

sha256sum (1) split (1) find (1) xargs (1)

References

Links