39 lines
959 B
Bash
Executable file
39 lines
959 B
Bash
Executable file
#!/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
|