-
Notifications
You must be signed in to change notification settings - Fork 0
/
autorun-back1.sh
71 lines (50 loc) · 2.4 KB
/
autorun-back1.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
66
67
68
69
70
71
#!/usr/bin/bash
BASE=/opt/projects/cpantesters
LOCK=$BASE/cpanstats-back1.lock
LOG=$BASE/cron/autorun-back1.log
date_format="%Y/%m/%d %H:%M:%S"
cd $BASE
clean_backup() {
PREFIX=$1
# Remove the previous backup, leaving 2
perl -E'@f = sort glob($ARGV[0] . "*.sql*"); @r = splice @f, 0, -2; unlink for @r' $PREFIX
}
if [ -f $LOCK ]
then
echo `date +"$date_format"` "Backup 1 already running" >>$LOG
else
touch $LOCK
echo `date +"$date_format"` "START" >>$LOG
DATE=`date +"%Y%m%d"`
cd $BASE/dbx
clean_backup metabase-email-backup
mysqldump -u barbie --skip-add-locks --add-drop-table --skip-disable-keys --skip-extended-insert metabase testers_email | bzip2 >metabase-email-backup-$DATE.sql.bz2
clean_backup testers-backup
mysqldump -u barbie --skip-add-locks --add-drop-table --skip-disable-keys --skip-extended-insert testers | bzip2 >testers-backup-$DATE.sql.bz2
clean_backup cpanstats-backup
mysqldump -u barbie --skip-add-locks --add-drop-table --skip-disable-keys --skip-extended-insert cpanstats >cpanstats-backup-$DATE.sql
bzip2 cpanstats-backup-$DATE.sql
# The previous two millions
clean_backup metabase-72m-backup
mysqldump -u barbie --skip-add-locks --where="id>71000000 AND id<=72000000" --skip-disable-keys --skip-extended-insert metabase metabase >metabase-72m-backup-$DATE.sql
bzip2 metabase-72m-backup-$DATE.sql
clean_backup metabase-73m-backup
mysqldump -u barbie --skip-add-locks --where="id>72000000 AND id<=73000000" --skip-disable-keys --skip-extended-insert metabase metabase >metabase-73m-backup-$DATE.sql
bzip2 metabase-73m-backup-$DATE.sql
# The current million
clean_backup metabase-backup
mysqldump -u barbie --skip-add-locks --where="id>73000000" --skip-disable-keys --skip-extended-insert metabase metabase >metabase-backup-$DATE.sql
bzip2 metabase-backup-$DATE.sql
#cp ../db/cpanstats.db cpanstats-$DATE.db
#bzip2 cpanstats-$DATE.db
#cd $BASE/generate
#echo `date +"$date_format"` "Updating SQLite cpanstats data..." >>$LOG
#perl bin/cpanstats-sqlite --config=data/settings.ini >>$LOG 2>&1
#cd $BASE/dbx
#echo `date +"$date_format"` "Compressing cpanstats data..." >>$LOG
#cp $BASE/db/cpanstats.db . ; gzip cpanstats.db
#cp $BASE/db/cpanstats.db . ; bzip2 cpanstats.db
#mv cpanstats.* /var/www/cpandevel
echo `date +"$date_format"` "STOP" >>$LOG
rm $LOCK
fi