#!/bin/bash # this pulls from host $1 to the current host. # not currently used, but it might be useful at some point source /a/bin/errhandle/err cd / old=$1 new=$HOSTNAME if [[ ! $old ]]; then echo "$0: error: no \$1 given, should be old host" exit 1 fi if ! timeout -s 9 2 ssh $old : ; then echo "$0: error: can't ssh to $old" fi for p in emacs firefox pidgin; do ssh $old killall $p ||: done # note: duplicated in check-subvol-stale last_a=$( vol=a for s in /mnt/root/btrbk/$vol.*; do f=${s##*/} unix_time=$(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s) printf "%s\n" $unix_time done | sort -r | head -n 1 ) if [[ $last_a != [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] ]]; then echo "$0: error: last_a bad value: $last_a" exit 1 fi # if last_a is recent enough, skip doing btrbk if (( last_a < $(date +%s) - 60*60 )); then if ! ssh $old btrbk-run -pvt $new; then echo "$0: error: failed btrbk-run" exit 1 fi fi switch-mail-host $old $new