@@ -116,134 +116,9 @@ readonly PID=$$
116116readonly _PREFIX=' rsync:'
117117readonly _TERMWIDTH=78
118118
119- DEFAULT_INFO=' progress2'
120- RSYNC_OPTIONS=(
121- # --8-bit-output # leave high-bit chars unescaped in output
122- # --acls # preserve ACLs (implies --perms)
123- # --address=ADDRESS # bind address for outgoing socket to daemon
124- # --append # append data onto shorter files
125- # --append-verify # --append w/old data in file checksum
126- # --archive # archive mode; equals: '--devices --group --links --owner --perms --recursive --specials --times'
127- # --atimes # preserve access (use) times
128- # --backup # make backups (see --suffix & --backup-dir)
129- # --backup-dir=DIR # make backups into hierarchy based in DIR
130- # --block-size=SIZE # force a fixed checksum block-size
131- # --blocking-io # use blocking I/O for the remote shell
132- # --bwlimit=RATE # limit socket I/O bandwidth
133- # --checksum # skip based on checksum, not mod-time & size
134- # --checksum-choice=STR # choose the checksum algorithm
135- # --checksum-seed=NUM # set block/file checksum seed (advanced)
136- # --chmod=CHMOD # affect file and/or directory permissions
137- # --chown=USER:GROUP # simple username/groupname mapping
138- # --compare-dest=DIR # also compare destination files relative to DIR
139- --compress # compress file data during the transfer
140- # --compress-choice=STR # choose the compression algorithm
141- # --compress-level=NUM # explicitly set compression level
142- # --contimeout=SECONDS # set daemon connection timeout in seconds
143- # --copy-as=USER[:GROUP] # specify user & optional group for the copy
144- # --copy-dest=DIR # ... and include copies of unchanged files
145- # --copy-dirlinks # transform symlink to dir into referent dir
146- # --copy-links # transform symlink into referent file/dir
147- # --copy-unsafe-links # only "unsafe" symlinks are transformed
148- # --crtimes # preserve create times (newness)
149- # --cvs-exclude # auto-ignore files in the same way CVS does
150- # --debug=FLAGS # fine-grained debug verbosity
151- # --delay-updates # put all updated files into place at end
152- --delete # delete extraneous files from dest dirs
153- # --delete-after # receiver deletes after transfer, not during
154- # --delete-before # receiver deletes before xfer, not during
155- # --delete-delay # find deletions during, delete after
156- # --delete-during # receiver deletes during the transfer
157- --delete-excluded # also delete excluded files from dest dirs
158- # --delete-missing-args # delete missing source args from destination
159- --devices # preserve device files (super-user only)
160- # --dirs # transfer directories without recursing
161- # --early-input=FILE # use FILE for daemon's early exec input
162- # --executability # preserve executability
163- # --existing # skip creating new files on receiver
164- # --fake-super # store/recover privileged attrs using xattrs
165- # --files-from=FILE # read list of source-file names from FILE
166- # --filter=RULE # add a file-filtering RULE
167- # --force # force deletion of dirs even if not empty
168- # --from0 # all *-from/filter files are delimited by 0s
169- # --fuzzy # find similar file for basis if no dest file
170- # --group # preserve group
171- # --groupmap=STRING # custom groupname mapping
172- # --hard-links # preserve hard links
173- --human-readable # output numbers in a human-readable format
174- # --iconv=CONVERT_SPEC # request charset conversion of filenames
175- # --ignore-errors # delete even if there are I/O errors
176- # --ignore-existing # skip updating files that exist on receiver
177- # --ignore-missing-args # ignore missing source args without error
178- # --ignore-times # don't skip files that match size and time
179- # --include-from=FILE # read include patterns from FILE
180- # --include=PATTERN # don't exclude files matching PATTERN
181- # --inplace # update destination files in-place
182- # --keep-dirlinks # treat symlinked dir on receiver as dir
183- # --link-dest=DIR # hardlink to files in DIR when unchanged
184- --links # copy symlinks as symlinks
185- # --list-only # list the files instead of copying them
186- # --log-file-format=FMT # log updates using the specified FMT
187- # --log-file=FILE # log what we're doing to the specified FILE
188- # --max-alloc=SIZE # change a limit relating to memory alloc
189- # --max-delete=NUM # don't delete more than NUM files
190- # --max-size=SIZE # don't transfer any file larger than SIZE
191- # --min-size=SIZE # don't transfer any file smaller than SIZE
192- # --mkpath # create the destination's path component
193- # --modify-window=NUM # set the accuracy for mod-time comparisons
194- # --munge-links # munge symlinks to make them safe & unusable
195- # --no-OPTION # turn off an implied OPTION (e.g. --no-D)
196- # --no-implied-dirs # don't send implied dirs with --relative
197- # --no-motd # suppress daemon-mode MOTD
198- # --numeric-ids # don't map uid/gid values by user/group name
199- # --omit-dir-times # omit directories from --times
200- # --omit-link-times # omit symlinks from --times
201- # --one-file-system # don't cross filesystem boundaries
202- # --only-write-batch=FILE # like --write-batch but w/o updating dest
203- # --open-noatime # avoid changing the atime on opened files
204- # --out-format=FORMAT # output updates using the specified FORMAT
205- # --outbuf=N|L|B # set out buffering to None, Line, or Block
206- # --owner # preserve owner (super-user only)
207- # --partial # keep partially transferred files
208- # --partial-dir=DIR # put a partially transferred file into DIR
209- # --password-file=FILE # read daemon-access password from FILE
210- --perms # preserve permissions
211- # --port=PORT # specify double-colon alternate port number
212- # --preallocate # allocate dest files before writing them
213- # --progress # show progress during transfer
214- # --protect-args # no space-splitting; wildcard chars only
215- # --protocol=NUM # force an older protocol version to be used
216- # --prune-empty-dirs # prune empty directory chains from file-list
217- # --quiet # suppress non-error messages
218- # --read-batch=FILE # read a batched update from FILE
219- --recursive # recurse into directories
220- # --relative # use relative path names
221- # --remote-option=OPT # send OPTION to the remote side only
222- # --remove-source-files # sender removes synchronized files (non-dir)
223- # --rsync-path=PROGRAM # specify the rsync to run on remote machine
224- # --safe-links # ignore symlinks that point outside the tree
225- # --size-only # skip files that match in size
226- # --skip-compress=LIST # skip compressing files with suffix in LIST
227- # --sockopts=OPTIONS # specify custom TCP options
228- # --sparse # turn sequences of nulls into sparse blocks
229- --specials # preserve special files
230- --stats # give some file-transfer stats
231- # --stderr=e|a|c # change stderr output mode (default: errors)
232- # --stop-after=MINS # Stop rsync after MINS minutes have elapsed
233- # --stop-at=y-m-dTh:m # Stop rsync at the specified point in time
234- # --suffix=SUFFIX # backup suffix (default ~ w/o --backup-dir)
235- # --super # receiver attempts super-user activities
236- # --temp-dir=DIR # create temporary files in directory DIR
237- # --timeout=SECONDS # set I/O timeout in seconds
238- --times # preserve modification times
239- # --update # skip files that are newer on the receiver
240- # --usermap=STRING # custom username mapping
241- # --verbose # increase verbosity
242- # --whole-file # copy files whole (w/o delta-xfer algorithm)
243- # --write-batch=FILE # write a batched update to FILE
244- # --write-devices # write to devices as files (implies --inplace)
245- # --xattrs # preserve extended attributes
246- )
119+ # #
120+ # # FUNCTIONS
121+ # #
247122
248123function check_prerequisites() {
249124 local required_commands=(awk grep head rsync screen)
@@ -406,30 +281,168 @@ function load_optional_config() {
406281 export RSYNC_INFO
407282}
408283
409- return 0 # FIXME: Remove
410-
411- #
412- # Parse ssh connection parameters
413- #
414- RSYNC_OPTIONS+=(
415- --rsh
416- " ssh -p ${SSH_PORT} -i $( printf ' %q' " ${SSH_KEY} " ) "
417- )
418-
284+ function collect_rsync_options() {
285+ local default_info=' progress2'
286+
287+ RSYNC_OPTIONS=(
288+ # --8-bit-output # leave high-bit chars unescaped in output
289+ # --acls # preserve ACLs (implies --perms)
290+ # --address=ADDRESS # bind address for outgoing socket to daemon
291+ # --append # append data onto shorter files
292+ # --append-verify # --append w/old data in file checksum
293+ # --archive # archive mode; equals: '--devices --group --links --owner --perms --recursive --specials --times'
294+ # --atimes # preserve access (use) times
295+ # --backup # make backups (see --suffix & --backup-dir)
296+ # --backup-dir=DIR # make backups into hierarchy based in DIR
297+ # --block-size=SIZE # force a fixed checksum block-size
298+ # --blocking-io # use blocking I/O for the remote shell
299+ # --bwlimit=RATE # limit socket I/O bandwidth
300+ # --checksum # skip based on checksum, not mod-time & size
301+ # --checksum-choice=STR # choose the checksum algorithm
302+ # --checksum-seed=NUM # set block/file checksum seed (advanced)
303+ # --chmod=CHMOD # affect file and/or directory permissions
304+ # --chown=USER:GROUP # simple username/groupname mapping
305+ # --compare-dest=DIR # also compare destination files relative to DIR
306+ --compress # compress file data during the transfer
307+ # --compress-choice=STR # choose the compression algorithm
308+ # --compress-level=NUM # explicitly set compression level
309+ # --contimeout=SECONDS # set daemon connection timeout in seconds
310+ # --copy-as=USER[:GROUP] # specify user & optional group for the copy
311+ # --copy-dest=DIR # ... and include copies of unchanged files
312+ # --copy-dirlinks # transform symlink to dir into referent dir
313+ # --copy-links # transform symlink into referent file/dir
314+ # --copy-unsafe-links # only "unsafe" symlinks are transformed
315+ # --crtimes # preserve create times (newness)
316+ # --cvs-exclude # auto-ignore files in the same way CVS does
317+ # --debug=FLAGS # fine-grained debug verbosity
318+ # --delay-updates # put all updated files into place at end
319+ --delete # delete extraneous files from dest dirs
320+ # --delete-after # receiver deletes after transfer, not during
321+ # --delete-before # receiver deletes before xfer, not during
322+ # --delete-delay # find deletions during, delete after
323+ # --delete-during # receiver deletes during the transfer
324+ --delete-excluded # also delete excluded files from dest dirs
325+ # --delete-missing-args # delete missing source args from destination
326+ --devices # preserve device files (super-user only)
327+ # --dirs # transfer directories without recursing
328+ # --early-input=FILE # use FILE for daemon's early exec input
329+ # --executability # preserve executability
330+ # --existing # skip creating new files on receiver
331+ # --fake-super # store/recover privileged attrs using xattrs
332+ # --files-from=FILE # read list of source-file names from FILE
333+ # --filter=RULE # add a file-filtering RULE
334+ # --force # force deletion of dirs even if not empty
335+ # --from0 # all *-from/filter files are delimited by 0s
336+ # --fuzzy # find similar file for basis if no dest file
337+ # --group # preserve group
338+ # --groupmap=STRING # custom groupname mapping
339+ # --hard-links # preserve hard links
340+ --human-readable # output numbers in a human-readable format
341+ # --iconv=CONVERT_SPEC # request charset conversion of filenames
342+ # --ignore-errors # delete even if there are I/O errors
343+ # --ignore-existing # skip updating files that exist on receiver
344+ # --ignore-missing-args # ignore missing source args without error
345+ # --ignore-times # don't skip files that match size and time
346+ # --include-from=FILE # read include patterns from FILE
347+ # --include=PATTERN # don't exclude files matching PATTERN
348+ # --inplace # update destination files in-place
349+ # --keep-dirlinks # treat symlinked dir on receiver as dir
350+ # --link-dest=DIR # hardlink to files in DIR when unchanged
351+ --links # copy symlinks as symlinks
352+ # --list-only # list the files instead of copying them
353+ # --log-file-format=FMT # log updates using the specified FMT
354+ # --log-file=FILE # log what we're doing to the specified FILE
355+ # --max-alloc=SIZE # change a limit relating to memory alloc
356+ # --max-delete=NUM # don't delete more than NUM files
357+ # --max-size=SIZE # don't transfer any file larger than SIZE
358+ # --min-size=SIZE # don't transfer any file smaller than SIZE
359+ # --mkpath # create the destination's path component
360+ # --modify-window=NUM # set the accuracy for mod-time comparisons
361+ # --munge-links # munge symlinks to make them safe & unusable
362+ # --no-OPTION # turn off an implied OPTION (e.g. --no-D)
363+ # --no-implied-dirs # don't send implied dirs with --relative
364+ # --no-motd # suppress daemon-mode MOTD
365+ # --numeric-ids # don't map uid/gid values by user/group name
366+ # --omit-dir-times # omit directories from --times
367+ # --omit-link-times # omit symlinks from --times
368+ # --one-file-system # don't cross filesystem boundaries
369+ # --only-write-batch=FILE # like --write-batch but w/o updating dest
370+ # --open-noatime # avoid changing the atime on opened files
371+ # --out-format=FORMAT # output updates using the specified FORMAT
372+ # --outbuf=N|L|B # set out buffering to None, Line, or Block
373+ # --owner # preserve owner (super-user only)
374+ # --partial # keep partially transferred files
375+ # --partial-dir=DIR # put a partially transferred file into DIR
376+ # --password-file=FILE # read daemon-access password from FILE
377+ --perms # preserve permissions
378+ # --port=PORT # specify double-colon alternate port number
379+ # --preallocate # allocate dest files before writing them
380+ # --progress # show progress during transfer
381+ # --protect-args # no space-splitting; wildcard chars only
382+ # --protocol=NUM # force an older protocol version to be used
383+ # --prune-empty-dirs # prune empty directory chains from file-list
384+ # --quiet # suppress non-error messages
385+ # --read-batch=FILE # read a batched update from FILE
386+ --recursive # recurse into directories
387+ # --relative # use relative path names
388+ # --remote-option=OPT # send OPTION to the remote side only
389+ # --remove-source-files # sender removes synchronized files (non-dir)
390+ # --rsync-path=PROGRAM # specify the rsync to run on remote machine
391+ # --safe-links # ignore symlinks that point outside the tree
392+ # --size-only # skip files that match in size
393+ # --skip-compress=LIST # skip compressing files with suffix in LIST
394+ # --sockopts=OPTIONS # specify custom TCP options
395+ # --sparse # turn sequences of nulls into sparse blocks
396+ --specials # preserve special files
397+ --stats # give some file-transfer stats
398+ # --stderr=e|a|c # change stderr output mode (default: errors)
399+ # --stop-after=MINS # Stop rsync after MINS minutes have elapsed
400+ # --stop-at=y-m-dTh:m # Stop rsync at the specified point in time
401+ # --suffix=SUFFIX # backup suffix (default ~ w/o --backup-dir)
402+ # --super # receiver attempts super-user activities
403+ # --temp-dir=DIR # create temporary files in directory DIR
404+ # --timeout=SECONDS # set I/O timeout in seconds
405+ --times # preserve modification times
406+ # --update # skip files that are newer on the receiver
407+ # --usermap=STRING # custom username mapping
408+ # --verbose # increase verbosity
409+ # --whole-file # copy files whole (w/o delta-xfer algorithm)
410+ # --write-batch=FILE # write a batched update to FILE
411+ # --write-devices # write to devices as files (implies --inplace)
412+ # --xattrs # preserve extended attributes
413+ )
419414
420- #
421- # Dry run parameters
422- #
423- # shellcheck disable=SC2248,SC2250
424- if [ $DRY_RUN_FLAG -eq 1 ]
425- then
415+ # SSH connection parameters
426416 RSYNC_OPTIONS+=(
427- --itemize-changes # output a change-summary for all updates
428- --dry-run # perform a trial run with no changes made
417+ --rsh
418+ " ssh -p ${SSH_PORT} -i $( printf ' %q ' " ${SSH_KEY} " ) "
429419 )
430- else
431- RSYNC_OPTIONS+=()
432- fi
420+
421+ # Info flags
422+ if [[ " ${RSYNC_INFO} " == " ${__NO_VALUE__} " ]]; then
423+ RSYNC_OPTIONS+=(
424+ --info
425+ " ${default_info} "
426+ )
427+ else
428+ RSYNC_OPTIONS+=(
429+ --info
430+ " ${RSYNC_INFO} "
431+ )
432+ fi
433+
434+ # Dry run
435+ if [[ ${DRY_RUN_FLAG} -eq 1 ]]; then
436+ RSYNC_OPTIONS+=(
437+ --itemize-changes # output a change-summary for all updates
438+ --dry-run # perform a trial run with no changes made
439+ )
440+ fi
441+
442+ export RSYNC_OPTIONS
443+ }
444+
445+ return 0 # FIXME: Remove
433446
434447
435448#
0 commit comments