diff --git a/tools/server-backup.sh b/tools/server-backup.sh new file mode 100755 index 0000000..be14234 --- /dev/null +++ b/tools/server-backup.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +#!/bin/sh + +ntfy() { + bash /opt/scripts/ntfy.sh -s "/etc/ixvd/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@" +} + +echo "creating backup with keep tag..." +restic \ + -r "/mnt/backups/restic/$(hostname)" \ + -p "/etc/ixvd/secrets/restic/$(hostname).secret" \ + backup \ + --tag keep \ + /srv /home /etc \ No newline at end of file diff --git a/tools/server-setup.d/30-cifs.sh b/tools/server-setup.d/30-cifs.sh index 19ad479..056fce8 100755 --- a/tools/server-setup.d/30-cifs.sh +++ b/tools/server-setup.d/30-cifs.sh @@ -4,7 +4,7 @@ if ! grep -q "# cifs mount backups" /etc/fstab; then echo "modifying fstab..." cp /etc/fstab /etc/fstab.$(date +"%H-%M-%S_%d-%m-%y").bak . /etc/ixvd/secrets/backups.cifs -cat<>/etc/fstab +cat<>/etc/fstab # cifs mount backups //$domain/backup /mnt/backups cifs credentials=/etc/ixvd/secrets/backups.cifs,file_mode=0777,dir_mode=0777,noperm 0 0 EOF diff --git a/tools/server-setup.d/50-backup-setup.sh b/tools/server-setup.d/50-backup-setup.sh new file mode 100755 index 0000000..3727f9f --- /dev/null +++ b/tools/server-setup.d/50-backup-setup.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +HOSTNAME=${HOSTNAME:-$(hostname)} + +if ! [ -d /mnt/backups/restic/$HOSTNAME ]; then + echo "creating restic repo for $HOSTNAME..." + if ! [ -f /etc/ixvd/secrets/restic/$HOSTNAME.secret ]; then + echo "no secret for $HOSTNAME found." + exit 1 + fi + restic \ + -r /mnt/backups/restic/$HOSTNAME \ + -p /etc/ixvd/secrets/restic/$HOSTNAME.secret \ + init +fi \ No newline at end of file