Add host-backup script
This commit is contained in:
parent
80a7334f59
commit
3bb298526b
4 changed files with 48 additions and 1 deletions
30
.bin/host-backup
Executable file
30
.bin/host-backup
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
_hostname="$(cat /proc/sys/kernel/hostname)"
|
||||
_host_backup_file="host-backup-$_hostname"
|
||||
if [ -x "$( which "$_host_backup_file")" ]
|
||||
then
|
||||
# shellcheck disable=SC1090
|
||||
. "$_host_backup_file"
|
||||
else
|
||||
echo "No host-backup file found: $_host_backup_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
host_backup_run
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
"_forget")
|
||||
host-backup forget --prune --keep-last 7 --keep-daily 14 --keep-weekly 8 --keep-monthly 8 --keep-yearly 2
|
||||
;;
|
||||
*)
|
||||
restic "$@"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,8 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
action=$(printf "shutdown\nreboot\nlogout\nautostart" | $DMENU)
|
||||
actions="backup-shutwdown
|
||||
shutdown
|
||||
reboot
|
||||
logout
|
||||
autostart"
|
||||
action=$(echo "$actions" | $DMENU)
|
||||
|
||||
_menu_shutdown_backup() {
|
||||
alacritty -e "host-backup"
|
||||
}
|
||||
|
||||
if [ -z "$action" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
notify-send "$(user-cleaner)"
|
||||
|
||||
case "$action" in
|
||||
backup-shutwdown) _menu_shutdown_backup && systemctl poweroff -i ;;
|
||||
shutdown) systemctl poweroff -i ;;
|
||||
reboot) systemctl reboot ;;
|
||||
logout) systemctl --user exit ;;
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
.bin/host-backup-portalo
|
||||
.config/env.d/99-secrets
|
||||
.ssh/config
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue