init
This commit is contained in:
commit
3bc0ded5a0
7 changed files with 102 additions and 0 deletions
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# Strix' final backup solution
|
8
fix-repo.sh
Executable file
8
fix-repo.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
for f in $(find . -iname '*.sh' -type 'f'); do
|
||||
if ! [ -x $f ]; then
|
||||
echo "fixing $f..."
|
||||
chmod +x $f
|
||||
fi
|
||||
done
|
15
install.sh
Executable file
15
install.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ "$(id -u)" = "0" ] || exit 1
|
||||
[ $# -lt 1 ] && exit 1
|
||||
|
||||
case $1 in
|
||||
node)
|
||||
cd nodes
|
||||
sh install.sh
|
||||
;;
|
||||
main)
|
||||
cd main
|
||||
sh install.sh
|
||||
;;
|
||||
esac
|
56
main/bin/update-backups.sh
Executable file
56
main/bin/update-backups.sh
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/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 -av --delete \
|
||||
sfbs@$host::sfbs/ \
|
||||
--link-dest "$latest_link" \
|
||||
--password-file="/var/lib/sfbs/rsync-password" \
|
||||
--include="/usr/local" \
|
||||
--exclude="/usr/*" \
|
||||
--exclude="/tmp/*" \
|
||||
--exclude="/sys/*" \
|
||||
--exclude="/dev/*" \
|
||||
--exclude="/proc/*" \
|
||||
--exclude="/run/*" \
|
||||
--exclude="/mnt/*" \
|
||||
--exclude="/media/*" \
|
||||
--exclude="/var/lib/sfbs/backups/*" \
|
||||
--exclude="/home/*/.rustup/*" \
|
||||
--exclude="/home/*/*Cache*/*" \
|
||||
--exclude="/home/*/*cache*/*" \
|
||||
--exclude="/home/*/.cache*/*" \
|
||||
--exclude="/home/*/.gradle/*" \
|
||||
--exclude="/home/*/.nvm/*" \
|
||||
--exclude="/home/*/Downloads/*" \
|
||||
--exclude="/home/*/Trash/*" \
|
||||
--exclude="/home/*/.config/chromium/*" \
|
||||
--exclude="/home/*/.local/*/pnpm/*" \
|
||||
--exclude="/home/*/.local/*/gnome-boxes/*" \
|
||||
--exclude="/home/*/JetBrains/Toolbox/apps/*" \
|
||||
--exclude="/home/*/code/*/dist/*" \
|
||||
--exclude="/home/*/code/*/venv/*" \
|
||||
--exclude="/home/*/code/*/target/*" \
|
||||
--exclude="/home/*/code/*/vendor/*" \
|
||||
--exclude="/home/*/code/*/output/*" \
|
||||
--exclude="/home/*/code/*/build/*" \
|
||||
--exclude="/home/*/code/*/node_modules/*" \
|
||||
"$backup_path"
|
||||
|
||||
rm -rf "$latest_link"
|
||||
ln -s "$backup_path" "$latest_link"
|
||||
|
||||
done
|
8
main/install.sh
Executable file
8
main/install.sh
Executable 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
|
8
nodes/etc/rsyncd.conf
Normal file
8
nodes/etc/rsyncd.conf
Normal file
|
@ -0,0 +1,8 @@
|
|||
[sfbs]
|
||||
path = /
|
||||
comment = "Full file-system share for sbfs"
|
||||
read only = true
|
||||
exclude = *.tar.old
|
||||
refuse options = delete
|
||||
auth users = @guset:deny, sfbs:ro
|
||||
secrets file = /var/lib/sfbs/rsync-auth
|
6
nodes/install.sh
Executable file
6
nodes/install.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
cp ./etc/rsyncd.conf /etc/rsyncd.conf
|
||||
[ -d "/var/lib/sfbs" ] || mkdir -p /var/lib/sfbs
|
||||
[ -f "/var/lib/sfbs/rsync-password" ] || openssl rand -hex 16 > /var/lib/sfbs/rsync-password
|
||||
[ -f "/var/lib/sfbs/rsync-auth" ] || (echo "sfbs:$(cat /var/lib/sfbs/rsync-password)" > /var/lib/sfbs/rsync-auth)
|
Loading…
Add table
Add a link
Reference in a new issue