summaryrefslogtreecommitdiff
path: root/other/backup-site.sh
blob: 4f4465a38887ffa67e3efcd7342b1bfc3257197d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
hostname=$(hostname)
r=0
if LOGFILE=$(mktemp)
then
	exec 3>&2
	exec 2>"$LOGFILE"
fi
set -x
rsync -aRi --delete --partial /./srv/*/public_html rsync.net:"$hostname"/ >/dev/null || r=2
mysqldump --all-databases | gzip -c | ssh rsync.net dd of="$hostname".sql || r=$((r+1))
if [ "$r" != 0 ]
then
	cat "$LOGFILE" >&3
fi
rm -f "$LOGFILE"
exit $r