copy.lib add looking for copy.exec in source directory for additional excludes
subv-xfer fix receive with sudomaster
parent
d30d814f74
commit
56ab717402
|
@ -203,7 +203,8 @@ subv_xfer() {
|
|||
echo "sudo ""$BTRFS_BIN"" sub snap $dest/$name.tmp $dest/$name$ext"
|
||||
echo "sudo ""$BTRFS_BIN"" sub del $dest/$name.tmp"
|
||||
else
|
||||
sudo "$BTRFS_BIN" send $([[ $tsnap ]] && echo "$tsnap" || echo "$src") | btrfs receive "$dest"
|
||||
# TODO: add mbuffer, show progress
|
||||
sudo "$BTRFS_BIN" send $([[ $tsnap ]] && echo "$tsnap" || echo "$src") | sudo "$BTRFS_BIN" receive "$dest"
|
||||
# FIXME: take a snapshot of the destination .tmp then remove .tmp, otherwise it will be readonly
|
||||
# sudo mv "$dest"/"$name".tmp "$dest"/"$name"$ext
|
||||
if is_subv -r "$dest"/"$name".tmp; then
|
||||
|
|
|
@ -39,7 +39,7 @@ Available Script Options
|
|||
-q, quiet, suppress progress
|
||||
-v, verbose, same as -v for rsync option, unset if -q is set
|
||||
-a, archive, same as -a for rsync option, basic identical copy with recursion
|
||||
-c, clean tranfer meaning will not transfer folder with trash, cache, log, nodemodules
|
||||
-c, cleaned tranfer meaning will not transfer folder with trash, cache, log
|
||||
-C, show excludes for clean transfer
|
||||
-h, this help text
|
||||
|
||||
|
@ -66,7 +66,7 @@ EOF
|
|||
;;
|
||||
c)
|
||||
# clean out unneeded folders like cache, trash, log
|
||||
args+=("--exclude-from=$COPY_MODULE_PATH/cache-trash-log.exc")
|
||||
args+=("--exclude-from=$COPY_MODULE_PATH/cache-trash-log.exc")
|
||||
;;
|
||||
C)
|
||||
echo "## clean transfer exclusions found in $COPY_MODULE_PATH/cache-trash-log.exc ##"
|
||||
|
@ -123,7 +123,7 @@ EOF
|
|||
return 0
|
||||
;;
|
||||
*)
|
||||
>&2 echo fatal: unknown remote script option $OPTION, aborting
|
||||
>&2 echo fatal: unknown remote script option "$OPTION", aborting
|
||||
help
|
||||
return 1
|
||||
;;
|
||||
|
@ -156,8 +156,8 @@ EOF
|
|||
fi
|
||||
[[ $DHOST && $SHOST ]] && echo this script can not process remote host to remote host transfer && return 5
|
||||
|
||||
[[ ! $SHOST ]] && SPATH=$(realpath $SPATH)
|
||||
[[ ! $DHOST ]] && DPATH=$(realpath $DPATH)
|
||||
[[ ! $SHOST ]] && SPATH=$(realpath "$SPATH")
|
||||
[[ ! $DHOST ]] && DPATH=$(realpath "$DPATH")
|
||||
|
||||
# additional argument processing
|
||||
debug $( ( IFS=$','; echo all remaining arguments: "$*" ) )
|
||||
|
@ -190,14 +190,14 @@ EOF
|
|||
fi
|
||||
fi
|
||||
|
||||
debug args: up before ssh: ${args[*]}
|
||||
debug args: up before ssh: "${args[*]}"
|
||||
|
||||
# is source or destination is remote, create -e ssh sync option
|
||||
if [[ $DHOST || $SHOST ]]; then
|
||||
debug remote copy, loading ssh
|
||||
debug ssh script args: ${sca[*]}
|
||||
debug ssh run args: ${sa[*]}
|
||||
debug remote host: ${DHOST:-$SHOST}
|
||||
debug ssh script args: "${sca[*]}"
|
||||
debug ssh run args: "${sa[*]}"
|
||||
debug remote host: "${DHOST:-$SHOST}"
|
||||
|
||||
if ! module_load ssh &>/dev/null; then
|
||||
echo unable to load ssh module
|
||||
|
@ -206,8 +206,8 @@ EOF
|
|||
echo "must be installed. Try \"module_load uci-shell-install; install_shell_network\""
|
||||
return 6
|
||||
fi
|
||||
if [[ ! $(get_user_host ${DHOST:-$SHOST}) ]]; then
|
||||
>&2 echo fatal: the host ${DHOST:-$SHOST} is not valid, aborting remote copy
|
||||
if [[ ! $(get_user_host "${DHOST:-$SHOST}") ]]; then
|
||||
>&2 echo fatal: the host "${DHOST:-$SHOST}" is not valid, aborting remote copy
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -216,14 +216,14 @@ EOF
|
|||
# echo $sshcmd
|
||||
# if ! sshcmd=$(ssh -l "${ssshargs[*]}" ${DHOST:-$SHOST}); then
|
||||
# double quotes on array expansion not good
|
||||
if ! sshcmd=$(ssh -l ${sca[*]} ${DHOST:-$SHOST} ${sa[*]}); then
|
||||
if ! sshcmd=$(ssh -l "${sca[*]}" "${DHOST:-$SHOST}" "${sa[*]}"); then
|
||||
echo failed to build ssh command for rsync, aborting
|
||||
debug sshcmd: ${sshcmd}
|
||||
debug sshcmd: "${sshcmd}"
|
||||
return 5
|
||||
fi
|
||||
debug sshcmd: ${sshcmd}
|
||||
debug sshcmd: "${sshcmd}"
|
||||
args+=("-e '$sshcmd'")
|
||||
debug args: inclcuding ssh: ${args[*]}
|
||||
debug args: inclcuding ssh: "${args[*]}"
|
||||
fi
|
||||
|
||||
# assemble remaining arguments from options
|
||||
|
@ -232,6 +232,10 @@ EOF
|
|||
[[ $mirror ]] && args+=(-a --numeric-ids --delete --force)
|
||||
[[ $Mirror ]] && args+=(--delete-excluded)
|
||||
|
||||
if [[ -f $SPATH/copy.exc ]]; then
|
||||
args+=("--exclude-from=$SPATH/copy.exc")
|
||||
fi
|
||||
|
||||
[[ ! -v PS1 ]] && noconfirm=true
|
||||
|
||||
cmd="$usesudo $(which rsync) ${args[*]} $SRC$([[ $insert ]] && echo "/") $DEST"
|
||||
|
@ -240,11 +244,11 @@ EOF
|
|||
if [[ ! $noconfirm ]]; then
|
||||
if [[ $insert ]]; then
|
||||
# todo mirror option
|
||||
confirm The contents within $([[ $SHOST ]] && echo $SHOST:)$SPATH will be \
|
||||
$([[ $mirror ]] && echo mirrored || echo placed ) inside $([[ $DHOST ]] && echo $DHOST:)$DPATH || return 0
|
||||
confirm The contents within $([[ $SHOST ]] && echo "$SHOST":)"$SPATH" will be \
|
||||
$([[ $mirror ]] && echo mirrored || echo placed ) inside $([[ $DHOST ]] && echo "$DHOST":)"$DPATH" || return 0
|
||||
else
|
||||
confirm the directory $(basename $SPATH) of $([[ $SHOST ]] && echo $SHOST:)$SPATH will be \
|
||||
$([[ $mirror ]] && echo mirrored || echo put ) at destination $([[ $DHOST ]] && echo $DHOST:)$DPATH/$(basename $SPATH) || return 0
|
||||
confirm the directory $(basename "$SPATH") of $([[ $SHOST ]] && echo "$SHOST":)"$SPATH" will be \
|
||||
$([[ $mirror ]] && echo mirrored || echo put ) at destination $([[ $DHOST ]] && echo "$DHOST":)"$DPATH"/$(basename "$SPATH") || return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -253,12 +257,12 @@ EOF
|
|||
fi
|
||||
|
||||
if [[ ! $quiet ]]; then [[ $exec ]] && echo executing the copy command || echo dry run of command, use -r to execute; fi
|
||||
if eval $cmd; then
|
||||
if eval "$cmd"; then
|
||||
[[ ! $quiet ]] && echo copy success!
|
||||
debug $cmd
|
||||
debug "$cmd"
|
||||
else
|
||||
>&2 echo remote copy failed
|
||||
>&2 echo $cmd
|
||||
>&2 echo "$cmd"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -277,7 +281,7 @@ EOF
|
|||
|
||||
[ $# -lt 2 ] && echo "both a directory and remote host need to be passed" && return 2
|
||||
dir=$1
|
||||
[[ ! -d $dir ]] && echo no directory $dir to mirror && return 1
|
||||
[[ ! -d $dir ]] && echo no directory "$dir" to mirror && return 1
|
||||
dest=$2
|
||||
shift 2
|
||||
copy $@ -i -a -c -M "$dir" "$dest:$dir" --exclude=archive*
|
||||
|
@ -291,7 +295,7 @@ EOF
|
|||
|
||||
[ $# -lt 2 ] && echo "both a directory and remote host need to be passed" && return 2
|
||||
dir=$1
|
||||
[[ ! -d $dir ]] && echo no directory $dir to mirror && return 1
|
||||
[[ ! -d $dir ]] && echo no directory "$dir" to mirror && return 1
|
||||
dest=$2
|
||||
shift 2
|
||||
copy "$@" -i -a "$dir" "$dest:$dir"
|
||||
|
@ -310,7 +314,7 @@ EOF
|
|||
if [[ ! $1 == "-"* ]]; then
|
||||
dest=$1
|
||||
shift
|
||||
echo pulling to alternate directory $dest
|
||||
echo pulling to alternate directory "$dest"
|
||||
fi
|
||||
copy "$@" -l -i "$src:$dir" "${dest:-dir}"
|
||||
copy "$@" -i "$src:$dir" "${dest:-dir}"
|
||||
|
@ -330,7 +334,7 @@ EOF
|
|||
|
||||
[ $# -lt 2 ] && echo "both a browser directory (within /opt/chromium) and remote host need to be passed" && return 2
|
||||
browser=$1
|
||||
[[ ! -d /opt/chromium/$browser ]] && echo no browser directory /opt/chromium/$browser && return 1
|
||||
[[ ! -d /opt/chromium/$browser ]] && echo no browser directory /opt/chromium/"$browser" && return 1
|
||||
dest=$2
|
||||
shift 2
|
||||
copy $@ -a -c -M "/opt/chromium/$browser" "$dest:/opt/chromium" --exclude=Singleton*
|
||||
|
|
Loading…
Reference in New Issue