sync/scripts/backup_edi.sh

64 lines
1.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
2023-05-06 05:44:49 +02:00
source /sync/home_external/.bash_aliases
shopt -s expand_aliases # make aliases work
2023-05-06 05:44:49 +02:00
###############################
### update local backup dir ###
###############################
BACKUP_DIR=/sync/backup
2024-03-17 14:08:34 +01:00
ensureDirectory $BACKUP_DIR
2023-05-06 05:44:49 +02:00
BACKUP_DIR_HOME=$BACKUP_DIR/home
2024-03-17 14:08:34 +01:00
ensureDirectory $BACKUP_DIR_HOME
backupDirectory $HOME/.ssh/ $BACKUP_DIR_HOME/.ssh/
2023-05-06 05:44:49 +02:00
BACKUP_DIR_ROOT=$BACKUP_DIR/root/etc
2024-03-17 14:08:34 +01:00
ensureRootDirectory $BACKUP_DIR_ROOT
2024-01-18 15:40:05 +01:00
sd rsync_backup /etc/hosts $BACKUP_DIR_ROOT/
2024-03-17 14:08:34 +01:00
sd rsync_backup /etc/ddclient.conf $BACKUP_DIR_ROOT/
backupRootDirectory /etc/ddclient/ $BACKUP_DIR_ROOT/ddclient/
backupRootDirectory /etc/letsencrypt/ $BACKUP_DIR_ROOT/letsencrypt/
backupRootDirectory /etc/nginx/ $BACKUP_DIR_ROOT/nginx/
backupRootDirectory /etc/ssh/ $BACKUP_DIR_ROOT/ssh/
backupRootDirectory /etc/wireguard/ $BACKUP_DIR_ROOT/wireguard/
backupRootDirectory /etc/docker/daemon.json $BACKUP_DIR_ROOT/docker/
backupRootDirectory() {
ensureRootDirectory $2
sd rsync_backup $1 $2
}
backupDirectory() {
ensureDirectory $2
rsync_backup $1 $2
}
ensureRootDirectory() {
ensureDirectory $1
sudo chown root:root $1
}
2023-05-06 05:44:49 +02:00
2024-03-17 14:08:34 +01:00
ensureDirectory() {
if [[ ! -e $1 ]]; then
mkdir -p $1
fi
}
2023-05-06 05:44:49 +02:00
#####################
### upload backup ###
#####################
2024-01-18 15:40:05 +01:00
if [[ "$1" == "--noupload" ]]; then
exit 0;
fi
2023-05-06 06:09:42 +02:00
sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" --filter="P /home/docker" /sync/backup/ fabian@garrus:/citadel/backup/edi/
2023-05-06 05:44:49 +02:00
sd rsync_backup -e "ssh -i /home/edi/.ssh/id_ed25519" /home/edi/docker/ fabian@garrus:/citadel/backup/edi/home/docker/