fix: stuff

This commit is contained in:
strix 2025-07-17 18:54:50 +02:00
parent 35fa60d02e
commit 374f0ebe98
5 changed files with 5 additions and 23 deletions

39
master/bin/update-backups.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/sh
set -o errexit
set -o nounset
set -o pipefail
backup_root="/var/lib/sfbs/backups"
for host in $(cat /var/lib/sfbs/hosts | grep -v '#'); do
dtime="$(date '+%Y-%m-%d_%H:%M:%S')"
latest_link="$backup_root/$host/latest"
backup_path="$backup_root/$host/$dtime"
mkdir -p $backup_path
echo "pulling $host's fs..."
rsync -avP --delete \
sfbs@$host::sfbs/ \
--link-dest "$latest_link" \
--password-file="/var/lib/sfbs/rsync-password" \
--include="/usr/local" \
--exclude="/usr/*" \
--exclude="/lib/*" \
--exclude="/bin/*" \
--exclude="/tmp/*" \
--exclude="/sys/*" \
--exclude="/dev/*" \
--exclude="/proc/*" \
--exclude="/run/*" \
--exclude="/mnt/*" \
--exclude="/media/*" \
--exclude="/var/lib/sfbs/backups/*" \
"$backup_path"
rm -rf "$latest_link"
ln -s "$backup_path" "$latest_link"
done

1
master/crontab Normal file
View file

@ -0,0 +1 @@
* * */4 0 root sh /opt/sfbs/bin/update-backups.sh

8
master/install.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
[ -d "/var/lib/sfbs/backups" ] || mkdir -p /var/lib/sfbs/backups
[ -d "/opt/sfbs" ] || mkdir -p /opt/sfbs
cp -r ./bin/. /opt/sfbs/bin
[ -f "/var/lib/sfbs/hosts" ] || (echo "# Here you can include hosts for sfbs." > /var/lib/sfbs/hosts)
[ -f "/var/lib/sfbs/rsync-password" ] || touch /var/lib/sfbs/rsync-password
chmod 600 /var/lib/sfbs/rsync-password