Commit c058515d authored by nimrod's avatar nimrod
Browse files

Server backup script.

Local automation for running offsite-backup (from the homelab repo) on
host01.
parent da3490fa
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
# vim: ft=bash

_server_backup() {
    local cur prev words cword opts
    _init_completion || return
    opts='-c'

    if [[ $cur == -* ]]
    then
        COMPREPLY=($(compgen -W "$opts" -- "$cur"))
    fi
}

complete -F _server_backup server-backup
+24 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

usage() {
    echo "$(basename "$0") [-c]"
}

if [ "$#" -eq 0 ]
then
    ssh -t host01.shore.co.il -o \
        "RemoteCommand tmux new-session -As backup sudo sh -c 'mount /dev/sdb1 /mnt && offsite-backup /mnt && umount /mnt'"
elif [ "$1" = '-c' ]
then
    if ssh host01.shore.co.il tmux has-session -t backup 2>/dev/null
    then
        echo 'Backup is still running.'
    else
        echo 'Backup has finished.'
        exit 1
    fi
else
    usage
    exit 1
fi