X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=btrbk-run;h=a1c6963a926b445454ca1d27634a56737e2d34da;hb=2cff2dd2b8040e6cbd721932ae09142881d7e0a6;hp=47138209f716975aede08790862bf7bd1035f734;hpb=4c39892ef8fa3379ce36adbe870723324cb71cea;p=distro-setup diff --git a/btrbk-run b/btrbk-run index 4713820..a1c6963 100755 --- a/btrbk-run +++ b/btrbk-run @@ -13,6 +13,9 @@ # 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 @@ -30,7 +33,6 @@ script_dir=$(dirname $(readlink -f "$BASH_SOURCE")) # note p/m is owned 1000:1000 and chmod 700 -targets=() 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 + # 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 ;; @@ -57,6 +60,8 @@ while true; do -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 ;; @@ -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 -if ! (( ${#targets[@]} )); then +if [[ ! -v targets ]]; then case $HOSTNAME in - x2) + x2|kw) if [[ $HOSTNAME == "$MAIL_HOST" ]]; then targets=($HOME_DOMAIN) fi ;; - treetowl) + tp) targets=(frodo) if [[ $HOSTNAME == "$MAIL_HOST" ]]; then if timeout -s 9 10 ssh x2 :; then @@ -89,6 +94,9 @@ if ! (( ${#targets[@]} )); then fi fi ;; + frodo) + targets=() + ;; *) 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 - 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" @@ -161,7 +177,7 @@ if ! which btrbk &>/dev/null; then fi cat >/etc/btrbk.conf <