-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup-sums.sh
executable file
·66 lines (60 loc) · 1.74 KB
/
backup-sums.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /bin/bash
#
# Tool to produce lists of MD5 sums for files in subdirectories.
#
# Assumption is that $rootdir contains directories. Each directory
# is a virtual host, or some other set of files for a domain.
# A report is produced for each directory. The report is stored
# in a parallel directory structure. By conventions we have
# directories like reports/www/domain.com, reports/mail/domain.com
# and the reports are named $hostname.md5
#
# The comparison script, backup-compare-sums.sh compares between
# two of these reports. See that script for more info.
#
check_dir()
{
# $rootder is the directory to scan
rootdir=$1
# $reportrootdir is where the report is stored
reportrootdir=$2
# all reports have the name $domain/$hostname.md5
cd "$rootdir"
for domain in *
do
echo $rootdir/$domain
mkdir -p "$reportrootdir/$domain"
filename="$reportrootdir/$domain/$(hostname).md5"
find $domain -type f -exec $MD5 $MD5OPT {} \; > "${filename}"
#sort "${filename}.tmp" > "$filename"
#rm "${filename}.tmp"
done
}
host=$(hostname)
if [[ $host = "johnk-desktop" ]] ; then
echo desk
report="/mnt/backup/reports/"
mkdir -p $report
cd $report
echo "start " $(date) > $host.log
MD5="md5sum"
MD5OPT="--tag"
#check_dir /mnt/backup/www $report/logs
#check_dir /mnt/backup/db $report/db
check_dir /mnt/backup/www $report/www
check_dir /mnt/backup/mail $report/mail
cd $report
echo "end " $(date) >> $host.log
elif [[ $host = "zanon.slaptech.net" ]] ; then
echo zanon
report="/home/johnk/reports/"
mkdir -p $report
cd $report
echo "start " $(date) > reports/$host.log
MD5="md5"
MD5OPT=""
check_dir /usr/local/www-domains/ $report/www/
check_dir /usr/local/vpopmail/domains/ $report/mail
cd $report
echo "end " $(date) >> $host.log
fi