From 5f9a2f93e16a7f7430f77c5d08d2701eb5ce9b0b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 11 Jun 2023 18:15:30 +0200 Subject: [PATCH 1/3] added homeserver scripts --- borg-backup | 1 - download-with-sftp.sh | 25 +++++++++++++++++++++++++ sftp-commands.txt | 3 +++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 download-with-sftp.sh create mode 100644 sftp-commands.txt diff --git a/borg-backup b/borg-backup index 1ccd537..f292f42 100755 --- a/borg-backup +++ b/borg-backup @@ -28,7 +28,6 @@ info "Starting backup" --exclude 'var/cache/*' \ --exclude 'srv/data/backup' \ --exclude '*/.Trash*' \ - --exclude '*/Trash*' \ \ ::'{hostname}-{now}' \ /etc \ diff --git a/download-with-sftp.sh b/download-with-sftp.sh new file mode 100755 index 0000000..92117f6 --- /dev/null +++ b/download-with-sftp.sh @@ -0,0 +1,25 @@ +#!/bin/bash +export BORG_PASSPHRASE="$(cat /root/secret/borg-snowboard.key)" +if [[ -z "${BORG_PASSPHRASE}" ]]; then + echo 'BORG_PASSPHRASE is not set, cannot continue' + exit +fi +cd /srv/data/backup/borg/snowboard +mkdir -p old +mv data* old +backupdir="data-$(date -I)" +mkdir -p $backupdir +cd $backupdir +sftp fileserver@cscherr.de < /usr/local/cron/sftp-commands.txt +status_download=$? +echo "finished downloading from snowboard. Status: $status_download" +borg check -v data/backup/borg/snowboard +status_check=$? +echo "finished checking the downloaded repo. Status: $status_check" +if [ "$status_check" -eq "0" ]; then + cd /srv/data/backup/borg/snowboard + rm -r old +else + echo "the new repo was not checked successfully, keeping old repo." +fi +echo $(date +"%Y-%m-%dT%H:%M:%S%z") diff --git a/sftp-commands.txt b/sftp-commands.txt new file mode 100644 index 0000000..d22b421 --- /dev/null +++ b/sftp-commands.txt @@ -0,0 +1,3 @@ +# get all files and directories in /data +# /data is the main dir. / is only a gateway dir with a bind mount +get -R /data From f79f22a8e81ef45c5fd10141b662c7385960a4b5 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 11 Jun 2023 18:21:23 +0200 Subject: [PATCH 2/3] test --- a | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 a diff --git a/a b/a new file mode 100644 index 0000000..e69de29 From 44e6f377df01a53e56a83ac10491368aadf1c1ac Mon Sep 17 00:00:00 2001 From: root Date: Sun, 11 Jun 2023 18:27:51 +0200 Subject: [PATCH 3/3] moving scripts to a more consistent layout --- a | 0 borg-backup => borg-backup.sh | 0 btrfs-raid-status => btrfs-raid-status.sh | 0 download-with-sftp.sh | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 a rename borg-backup => borg-backup.sh (100%) rename btrfs-raid-status => btrfs-raid-status.sh (100%) diff --git a/a b/a deleted file mode 100644 index e69de29..0000000 diff --git a/borg-backup b/borg-backup.sh similarity index 100% rename from borg-backup rename to borg-backup.sh diff --git a/btrfs-raid-status b/btrfs-raid-status.sh similarity index 100% rename from btrfs-raid-status rename to btrfs-raid-status.sh diff --git a/download-with-sftp.sh b/download-with-sftp.sh index 92117f6..cd5f11e 100755 --- a/download-with-sftp.sh +++ b/download-with-sftp.sh @@ -10,7 +10,7 @@ mv data* old backupdir="data-$(date -I)" mkdir -p $backupdir cd $backupdir -sftp fileserver@cscherr.de < /usr/local/cron/sftp-commands.txt +sftp fileserver@cscherr.de < /usr/local/cron/scripts/sftp-commands.txt status_download=$? echo "finished downloading from snowboard. Status: $status_download" borg check -v data/backup/borg/snowboard