feat: setup backups
This commit is contained in:
parent
08d731adc2
commit
89103dc0ee
3 changed files with 31 additions and 1 deletions
15
tools/server-backup.sh
Executable file
15
tools/server-backup.sh
Executable file
|
@ -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
|
|
@ -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<<EOF>>/etc/fstab
|
||||
cat<<EOF >>/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
|
||||
|
|
15
tools/server-setup.d/50-backup-setup.sh
Executable file
15
tools/server-setup.d/50-backup-setup.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue