Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
# 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
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment