init
This commit is contained in:
commit
3bc0ded5a0
7 changed files with 102 additions and 0 deletions
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
|
Loading…
Add table
Add a link
Reference in a new issue