#!/bin/bash export MY_WHICH=`which which` export MY_RSYNC_BIN=`${MY_WHICH} rsync` export MY_FSCK_GRACE_TIME="10" ## Grace time in seconds as in having `sleep 1s` running in loop for every count... export MY_FSCK_LONG_NAME="$0" export MY_FSCK_SHORT_NAME=`basename ${MY_FSCK_LONG_NAME}` export MY_FSCK_FUCKUP_BASENAME="safe-rsync-testing-" export MY_FSCK_FUCKUP_TIMESTAMP=`date "+%Y%m%dT%H%M%S.%N_%Z"` export MY_FSCK_FUCKUP_PWD="/root/" export MY_FSCK_FUCKUP_NAME="${MY_FSCK_FUCKUP_PWD}${MY_FSCK_FUCKUP_BASENAM}${MY_FSCK_FUCKUP_TIMESTAMP}" export MY_FSCK_LOG_FILE="${MY_FSCK_FUCKUP_NAME}.log" export MY_FSCK_BATCH_FILE="${MY_FSCK_FUCKUP_NAME}_batch" ################################################################################ ## Some Stuff # The CVSIGNORE environment variable supplements any ignore patterns in .cvsignore files. See the --cvs-exclude option for more details. unset CVSIGNORE # Specify a default --iconv setting using this environment variable. (First supported in 3.0.0.) unset RSYNC_ICONV # Specify a non-zero numeric value if you want the --protect-args option to be enabled by default, or a zero value to make sure that it is disabled by default. (First supported in 3.1.0.) unset RSYNC_PROTECT_ARGS export RSYNC_PROTECT_ARGS=1 # The RSYNC_RSH environment variable allows you to override the default shell used as the transport for rsync. Command line options are permitted after the command name, just as in the -e option. unset RSYNC_RSH # The RSYNC_PROXY environment variable allows you to redirect your rsync client to use a web proxy when connecting to a rsync daemon. You should set RSYNC_PROXY to a hostname:port pair. unset RSYNC_PROXY # Setting RSYNC_PASSWORD to the required password allows you to run authenticated rsync connections to an rsync daemon without user intervention. Note that this does not supply a password to a remote shell transport such as ssh; to learn how to do that, consult the remote shell?s documentation. unset RSYNC_PASSWORD echo " \$0 = $0" echo " \$* = $*" echo " ($0 $*)" echo " \$1 = $1" echo " \$2 = $2" echo " \$3 = $3" echo " \$4 = $4" echo " \$5 = $5" echo "MY_FSCK_FUCKUP = $MY_FSCK_FUCKUP_testing" echo "MY_FSCK_LONG_NAME = ${MY_FSCK_LONG_NAME}" echo "MY_FSCK_SHORT_NAME = ${MY_FSCK_SHORT_NAME}" echo "MY_WHICH = ${MY_WHICH}" echo "MY_RSYNC_BIN = ${MY_RSYNC_BIN}" OUR_RSYNC_OPTS_STRING="" # OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}" OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--verbose " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--human-readable " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--progress " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--stats " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--itemize-changes " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--one-file-system " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--checksum " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--archive " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--recursive " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--perms " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--executability " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--links " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--copy-unsafe-links " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--times " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--group " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--owner " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--sparse " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--partial " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--acls " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--xattrs " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--hard-links " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--protect-args " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--compress-level=0 " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--no-compress " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--super " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--specials " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--preallocate " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--copy-dirlinks " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--usermap=38242:1975 " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--groupmap=38242:1975 " OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--outbuf=block " ##OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--timeout=10 " ##OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--dry-run " ##OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--log-file-format=FMT " ##OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--log-file-format=\"%Y%m%dT%H%M%S.%N_%Z\" " # OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--log-file=${MY_FSCK_LOG_FILE} " # OUR_RSYNC_OPTS_STRING="${OUR_RSYNC_OPTS_STRING}--only-write-batch=${MY_FSCK_BATCH_FILE} " OUR_FSCK_FINAL_RSYNC_COMMAND="${MY_RSYNC_BIN} ${OUR_RSYNC_OPTS_STRING}${1} ${2}" echo -e "\n\n" echo "###### DANGER ############ DANGER ############ DANGER ############ DANGER ######" echo "#" echo "#" echo "# executing the following command in ${MY_FSCK_GRACE_TIME} seconds:" echo "#" echo "#" echo "" echo "SUPERDATE = %Y%m%dT%H%M%S.%N_%Z" echo "SUPERDATE = `date +%Y%m%dT%H%M%S.%N_%Z` (\`date %Y%m%dT%H%M%S.%N_%Z\`)" echo "" echo "${OUR_FSCK_FINAL_RSYNC_COMMAND}" echo "" echo "" echo "#" echo "#" echo "# delay for..." echo -en "${MY_FSCK_GRACE_TIME}... " for MY_FSCK_GRACE_TIME_COUNTER in `seq 1 ${MY_FSCK_GRACE_TIME}` ; do sleep 1s MY_FSCK_GRACE_TIME_COUNTER_REMAINING=$((${MY_FSCK_GRACE_TIME}-${MY_FSCK_GRACE_TIME_COUNTER})) echo -en "\n\n${MY_FSCK_GRACE_TIME_COUNTER_REMAINING}... " done #echo "you got lucky!!!" echo "let's go!" $OUR_FSCK_FINAL_RSYNC_COMMAND exit 254 ################################################################################ ## --remove-source-files ## This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and ## have been successfully duplicated on the receiving side. ## -B, --block-size=BLOCKSIZE ## This forces the block size used in rsync?s delta-transfer algorithm to a fixed value. It is normally selected based on ## the size of each file being updated. See the technical report for details. ################################################################################ ## --list-only ## This option will cause the source files to be listed instead of transferred. This option is inferred if there is a single ## source arg and no destination specified, so its main uses are: (1) to turn a copy command that includes a destination arg ## into a file-listing command, or (2) to be able to specify more than one source arg (note: be sure to include the destina? ## tion). Caution: keep in mind that a source arg with a wild-card is expanded by the shell into multiple args, so it is ## never safe to try to list such an arg without using this option. For example: ## ## rsync -av --list-only foo* dest/ ## ## Starting with rsync 3.1.0, the sizes output by --list-only are affected by the --human-readable option. By default they ## will contain digit separators, but higher levels of readability will output the sizes with unit suffixes. Note also that ## the column width for the size output has increased from 11 to 14 characters for all human-readable levels. Use --no-h if ## you want just digits in the sizes, and the old column width of 11 characters. ## ## Compatibility note: when requesting a remote listing of files from an rsync that is version 2.6.3 or older, you may ## encounter an error if you ask for a non-recursive listing. This is because a file listing implies the --dirs option w/o ## --recursive, and older rsyncs don?t have that option. To avoid this problem, either specify the --no-dirs option (if you ## don?t need to expand a directory?s content), or turn on recursion and exclude the content of subdirectories: -r ## --exclude='/*/*'. ## ## --bwlimit=RATE ## This option allows you to specify the maximum transfer rate for the data sent over the socket, specified in units per sec? ## ond. The RATE value can be suffixed with a string to indicate a size multiplier, and may be a fractional value (e.g. ## "--bwlimit=1.5m"). If no suffix is specified, the value will be assumed to be in units of 1024 bytes (as if "K" or "KiB" ## had been appended). See the --max-size option for a description of all the available suffixes. A value of zero specifies ## no limit. ## ## For backward-compatibility reasons, the rate limit will be rounded to the nearest KiB unit, so no rate smaller than 1024 ## bytes per second is possible. ## ## Rsync writes data over the socket in blocks, and this option both limits the size of the blocks that rsync writes, and ## tries to keep the average transfer rate at the requested limit. Some "burstiness" may be seen where rsync writes out a ## block of data and then sleeps to bring the average rate into compliance. ## ## Due to the internal buffering of data, the --progress option may not be an accurate reflection on how fast the data is ## being sent. This is because some files can show up as being rapidly sent when the data is quickly buffered, while other ## can show up as very slow when the flushing of the output buffer occurs. This may be fixed in a future version. ## ## --write-batch=FILE ## Record a file that can later be applied to another identical destination with --read-batch. See the "BATCH MODE" section ## for details, and also the --only-write-batch option. ## ## --only-write-batch=FILE ## Works like --write-batch, except that no updates are made on the destination system when creating the batch. This lets ## you transport the changes to the destination system via some other means and then apply the changes via --read-batch. ## ## Note that you can feel free to write the batch directly to some portable media: if this media fills to capacity before the ## end of the transfer, you can just apply that partial transfer to the destination and repeat the whole process to get the ## rest of the changes (as long as you don?t mind a partially updated destination system while the multi-update cycle is hap? ## pening). ## ## Also note that you only save bandwidth when pushing changes to a remote system because this allows the batched data to be ## diverted from the sender into the batch file without having to flow over the wire to the receiver (when pulling, the ## sender is remote, and thus can?t write the batch). ## ## --read-batch=FILE ## Apply all of the changes stored in FILE, a file previously generated by --write-batch. If FILE is -, the batch data will ## be read from standard input. See the "BATCH MODE" section for details. ## ## ## --checksum-seed=NUM ## Set the checksum seed to the integer NUM. This 4 byte checksum seed is included in each block and MD4 file checksum cal? ## culation (the more modern MD5 file checksums don?t use a seed). By default the checksum seed is generated by the server ## and defaults to the current time() . This option is used to set a specific checksum seed, which is useful for applica? ## tions that want repeatable block checksums, or in the case where the user wants a more random checksum seed. Setting NUM ## to 0 causes rsync to use the default of time() for checksum seed. ## ################################################################################ ## --out-format=FORMAT ## This allows you to specify exactly what the rsync client outputs to the user on a per-update basis. The format is a text ## string containing embedded single-character escape sequences prefixed with a percent (%) character. A default format of ## "%n%L" is assumed if either --info=name or -v is specified (this tells you just the name of the file and, if the item is a ## link, where it points). For a full list of the possible escape characters, see the "log format" setting in the ## rsyncd.conf manpage. ## ## Specifying the --out-format option implies the --info=name option, which will mention each file, dir, etc. that gets ## updated in a significant way (a transferred file, a recreated symlink/device, or a touched directory). In addition, if ## the itemize-changes escape (%i) is included in the string (e.g. if the --itemize-changes option was used), the logging of ## names increases to mention any item that is changed in any way (as long as the receiving side is at least 2.6.4). See the ## --itemize-changes option for a description of the output of "%i". ## ## Rsync will output the out-format string prior to a file?s transfer unless one of the transfer-statistic escapes is ## requested, in which case the logging is done at the end of the file?s transfer. When this late logging is in effect and ## --progress is also specified, rsync will also output the name of the file being transferred prior to its progress informa? ## tion (followed, of course, by the out-format output). ## ################################################################################ ## ## --log-file-format=FORMAT ## This allows you to specify exactly what per-update logging is put into the file specified by the --log-file option (which ## must also be specified for this option to have any effect). If you specify an empty string, updated files will not be ## mentioned in the log file. For a list of the possible escape characters, see the "log format" setting in the rsyncd.conf ## manpage. ## ## The default FORMAT used if --log-file is specified and this option is not is ?%i %n%L?. ## ################################################################################ ################################################################################ # oldoptsfu -valES --no-compress scSrix ## -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) ## -r, --recursive recurse into directories ## -l, --links copy symlinks as symlinks ## -p, --perms preserve permissions ## -t, --times preserve modification times ## -g, --group preserve group ## -o, --owner preserve owner (super-user only) ## ## -v, --verbose increase verbosity ## -A, --acls preserve ACLs (implies -p) ## -H, --hard-links preserve hard links ## -s, --protect-args no space-splitting; wildcard chars only ## -S, --sparse handle sparse files efficiently ## -h, --human-readable output numbers in a human-readable format ## --progress show progress during transfer ## --stats give some file-transfer stats ## -x, --one-file-system don_t cross filesystem boundaries ## -c, --checksum skip based on checksum, not mod-time & size ## --copy-unsafe-links only "unsafe" symlinks are transformed ## -E, --executability preserve executability ## --partial keep partially transferred files ## -i, --itemize-changes output a change-summary for all updates ## ## --log-file=FILE log what we_re doing to the specified FILE ## --log-file-format=FMT log updates using the specified FMT ## ## --inplace ## potentially dangerous, only for initial copy ## --numeric-ids don_t map uid/gid values by user/group name ## --usermap=STRING custom username mapping ## --groupmap=STRING custom groupname mapping ## --chown=USER:GROUP simple username/groupname mapping ## ## --no-compress ## ## -z, --compress compress file data during the transfer ## --compress-level=NUM explicitly set compression level ## --skip-compress=LIST skip compressing files with suffix in LIST ## #### --no-OPTION turn off an implied OPTION (e.g. --no-D) ## --only-write-batch=/root/hackyshome_rsync.log