added homeserver scripts

This commit is contained in:
root 2023-06-11 18:15:30 +02:00
parent a1ee59ba09
commit 5f9a2f93e1
3 changed files with 28 additions and 1 deletions

View File

@ -28,7 +28,6 @@ info "Starting backup"
--exclude 'var/cache/*' \
--exclude 'srv/data/backup' \
--exclude '*/.Trash*' \
--exclude '*/Trash*' \
\
::'{hostname}-{now}' \
/etc \

25
download-with-sftp.sh Executable file
View File

@ -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")

3
sftp-commands.txt Normal file
View File

@ -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