#!/bin/bash -lx set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR gen_args=() do_snapshot=true while [[ $1 ]]; do case $1 in -n) do_snapshot=false; shift ;; --) shift; break ;; -*) gen_args+=($1) ; shift ;; *) host=$1; shift ;; esac done # arch and debian don't play nice with unison. # "connection lost" on unison-gtk, with bignum errs in term, # and simply freezing on cli, all means compiled under # different ocaml versions. # I had the great realization that unison is a self contained # binary with no special runtime dependencies. # However, I got a gtk error running the ui version. # todo: I should test pushing my unison version instead # of pulling it. /p/c/subdir_files/.unison/gen ${gen_args[@]} if [[ ! $host ]]; then echo "$0: error: expected argument for hostname" exit 1 fi # todo: this doesn't deal with if the host is running arch too # note, without bash, it prints some crap about tty # on an uncustomized jessie install. scp /usr/bin/unison root@$host:/usr/local/bin echo "$0: egen args ${gen_args[@]}" if $do_snapshot; then unison-snapshot if ! ssh root@$host unison-snapshot; then if [[ ! ${gen_args[@]} ]]; then # gen_args are all about syncing with new systems where # we could expect the remote snapshot to not be available yet. echo "$0: error: failed remote unison-snapshot" exit 1 fi fi fi f=unison-gtk type -t $f &>/dev/null || f=unison-gtk2 # for arch if s $f "$host"; then if [[ $host == frodo ]]; then # only send data to the machine i do full backups to p=/p/c/machine_specific/$HOSTNAME/.unison/ s rsync -rlptgohi $p root@$host:$p fi p=/p/c/machine_specific/$host/.unison/ s rsync -rlptgohvi root@$host:$p $p fi