-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractWikiData
More file actions
executable file
·87 lines (58 loc) · 2.13 KB
/
extractWikiData
File metadata and controls
executable file
·87 lines (58 loc) · 2.13 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
#########
#Variables
#########
backupdirname="InnoboxMediaWikiBackupv1"
mountpt="/mnt/backup"
backupPath=$mountpt/$backupdirname/
LocalSettings="/etc/mediawiki/LocalSettings.php"
dumpBackup="/usr/share/mediawiki/maintenance/dumpBackup.php"
Images="/var/lib/mediawiki/images/"
wikiPass=`cat/etc/mediawiki/wiki_password.txt`
##########
Delete old backup if we run low on space
#########
#modified from "Limit Disk Usage" script available at:
#http://wiki.rdiff-backup.org/wiki/index.php/LimitDiskUsage
#!/bin/bash
# backup destination dir
backupdir=/mnt/backups/foo
# rdiff-backup binary
rdiffbackup=/usr/bin/rdiff-backup
# remove old increments from the backup as long as du reports
# more bytes used by the backup dir than the following limit
maxbytes=$((350 * 1024 * 1024 * 1024))
# but never delete increments younger than the following limit in seconds
keepseconds=$((7 * 60 * 60 * 24))
# gather the list of timestamps of all backup increments into an array
increments=($($rdiffbackup --list-increments --parsable-output $backupdir | grep -o "^\w*"))
# while we still have at least two increments,
# and we are allowed to delete the oldest increment,
# and du reports more disk usage than allowed,
# remove the oldest increment
while ((
${#increments[*]} > 1 &&
$(echo "$(date +%s) - ${increments[0]} > $keepseconds" | bc) == 1 &&
$(echo "$(du -k -s $backupdir | grep -o "^\w*") * 1024 > $maxbytes" | bc) == 1 ))
do
$rdiffbackup --remove-older-than $(echo "${increments[0]} + 1" | bc) $backupdir || exit
unset increments[0]
increments=(${increments[*]})
done
########
Extract Data From Wiki
########
echo "Dumping the MySQL Database"
#Dump the MySQL database
/usr/bin/nice -n 19 mysqldump -uwiki_user -p$wikiPass --add-drop-table wiki_db -c
echo "Taring the image files and LocalSettings"
#Create a tar of all of the associate files:
/usr/bin/nice -n 19 tar -czvf $backupdir/wiki-supportfiles-$timestamp.tgz $LocalSettings $Images
sleep 1
echo "Starting the XML Dump"
########
Invoke rdiff backup
$######
/usr/bin/nice -n 19 php $dumpBackup --full | gzip > $backupdir/wiki-XML-$timestamp.xml.gz
echo "Finished"
exit 0