iankelling.org
/
git
/
distro-setup
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
various fixes and improvements
[distro-setup]
/
btrbk-run
diff --git
a/btrbk-run
b/btrbk-run
index 47138209f716975aede08790862bf7bd1035f734..a1c6963a926b445454ca1d27634a56737e2d34da 100755
(executable)
--- a/
btrbk-run
+++ b/
btrbk-run
@@
-13,6
+13,9
@@
# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+# todo: remove old leaf subvols, like keep up to 1 month or something.
+
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
@@
-30,7
+33,6
@@
script_dir=$(dirname $(readlink -f "$BASH_SOURCE"))
# note p/m is owned 1000:1000 and chmod 700
# note p/m is owned 1000:1000 and chmod 700
-targets=()
mountpoints=()
rsync_mountpoint=/q
mountpoints=()
rsync_mountpoint=/q
@@
-50,6
+52,7
@@
temp=$(getopt -l help cl:m:nprt:vh "$@") || usage 1
eval set -- "$temp"
while true; do
case $1 in
eval set -- "$temp"
while true; do
case $1 in
+ # only creates the config file, does not run btrbk
-c) conf_only=true; shift ;;
-l) rate_limit=$2; shift 2 ;;
-m) IFS=, mountpoints=($2); unset IFS; shift 2 ;;
-c) conf_only=true; shift ;;
-l) rate_limit=$2; shift 2 ;;
-m) IFS=, mountpoints=($2); unset IFS; shift 2 ;;
@@
-57,6
+60,8
@@
while true; do
-p) progress_arg="--progress"; shift ;;
# btrbk arg: Resume only. Skips snapshot creation.
-r) resume_arg=-r; shift ;;
-p) progress_arg="--progress"; shift ;;
# btrbk arg: Resume only. Skips snapshot creation.
-r) resume_arg=-r; shift ;;
+ # empty is valid for just doing local snapshot. we have default hosts
+ # we will populate
-t) IFS=, targets=($2); unset IFS; shift 2 ;;
-v) verbose=true; verbose_arg=-v; shift ;;
-h|--help) usage ;;
-t) IFS=, targets=($2); unset IFS; shift 2 ;;
-v) verbose=true; verbose_arg=-v; shift ;;
-h|--help) usage ;;
@@
-74,14
+79,14
@@
fi
echo -e "$0: options: conf_only=$conf_only\ndry_run=$dry_run\nresume_arg=$resume_arg\nrate_limit=$rate_limit\nverbose=$verbose"
# set default targets
echo -e "$0: options: conf_only=$conf_only\ndry_run=$dry_run\nresume_arg=$resume_arg\nrate_limit=$rate_limit\nverbose=$verbose"
# set default targets
-if
! (( ${#targets[@]} ))
; then
+if
[[ ! -v targets ]]
; then
case $HOSTNAME in
case $HOSTNAME in
- x2)
+ x2
|kw
)
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
targets=($HOME_DOMAIN)
fi
;;
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
targets=($HOME_DOMAIN)
fi
;;
- t
reetowl
)
+ t
p
)
targets=(frodo)
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
if timeout -s 9 10 ssh x2 :; then
targets=(frodo)
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
if timeout -s 9 10 ssh x2 :; then
@@
-89,6
+94,9
@@
if ! (( ${#targets[@]} )); then
fi
fi
;;
fi
fi
;;
+ frodo)
+ targets=()
+ ;;
*)
echo "$0: error: no default targets for this host, use -t"
exit 1
*)
echo "$0: error: no default targets for this host, use -t"
exit 1
@@
-108,15
+116,23
@@
if (( ${#mountpoints[@]} )); then
fi
done
else # set default mountpoints
fi
done
else # set default mountpoints
- prospective_mps=(/a /q)
- if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
- prospective_mps+=(/o)
- fi
- for tg in ${targets[@]}; do
- if [[ $tg == frodo && $HOSTNAME == treetowl ]]; then
- prospective_mps+=(/i)
- fi
- done
+ case $HOSTNAME in
+ frodo)
+ prospective_mps=(/i)
+ ;;
+ *)
+ prospective_mps=(/a /q)
+ if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
+ prospective_mps+=(/o)
+ fi
+ ;;
+ esac
+ case ${targets[0]} in
+ kw|kww)
+ prospective_mps=(/a)
+ ;;
+ esac
+
for mp in ${prospective_mps[@]}; do # default mountpoints to sync
if [[ -e /nocow/btrfs-stale/$mp ]]; then
echo "$0: warning: $mp stale, not adding to default mountpoints"
for mp in ${prospective_mps[@]}; do # default mountpoints to sync
if [[ -e /nocow/btrfs-stale/$mp ]]; then
echo "$0: warning: $mp stale, not adding to default mountpoints"
@@
-161,7
+177,7
@@
if ! which btrbk &>/dev/null; then
fi
cat >/etc/btrbk.conf <<EOF
fi
cat >/etc/btrbk.conf <<EOF
-ssh_identity /root/.ssh/
id_rsa
+ssh_identity /root/.ssh/
home
# Just a guess that local7 is a good facility to pick.
# It's a bit odd that the transaction log has to be logged to
# a file or syslog, while other output is sent to std out.
# Just a guess that local7 is a good facility to pick.
# It's a bit odd that the transaction log has to be logged to
# a file or syslog, while other output is sent to std out.