... | ... |
@@ -0,0 +1,58 @@ |
1 |
+#!/bin/bash |
|
2 |
+ |
|
3 |
+mountpoint=/backup |
|
4 |
+ |
|
5 |
+alreadymounted=1 |
|
6 |
+badmodload=2 |
|
7 |
+notmounted=3 |
|
8 |
+umountfailure=4 |
|
9 |
+unloadfailure=5 |
|
10 |
+ |
|
11 |
+owncloudpath=/var/www/owncloud |
|
12 |
+datapath=$owncloudpath/data |
|
13 |
+configpath=$owncloudpath/config |
|
14 |
+dbname=owncloud |
|
15 |
+ |
|
16 |
+PATH=/usr/sbin:/usr/bin:/sbin:/bin |
|
17 |
+ |
|
18 |
+test -d $mountpoint || mkdir $mountpoint |
|
19 |
+ |
|
20 |
+if grep -q $mountpoint /proc/mounts; then |
|
21 |
+ echo "$mountpoint déjà monté, arrêt" |
|
22 |
+ exit $alreadymounted |
|
23 |
+fi |
|
24 |
+ |
|
25 |
+if ! test -d /sys/module/vboxsf; then |
|
26 |
+ if ! modprobe vboxsf; then |
|
27 |
+ echo "module vboxsf non chargé correctement, abandon" |
|
28 |
+ exit $badmodload |
|
29 |
+ fi |
|
30 |
+fi |
|
31 |
+ |
|
32 |
+if ! mount -t vboxsf -o uid=www-data,gid=www-data backup $mountpoint; then |
|
33 |
+ echo "impossible de monter $mountpoint" |
|
34 |
+ exit $notmounted |
|
35 |
+fi |
|
36 |
+ |
|
37 |
+rsync -Avax $configpath $mountpoint/ > /var/log/${0##*/} 2>&1 |
|
38 |
+rsync -Avax --exclude="/etc/ssh/ssh_host_*" /etc $mountpoint/ >> /var/log/${0##*/} 2>&1 |
|
39 |
+rsync -Avax --exclude=lost+found --exclude="data/owncloud.log*" $datapath $mountpoint/ >> /var/log/${0##*/} 2>&1 |
|
40 |
+mysqldump -u owncloud_usr --password=$(awk -F"'" '/dbpassword/{print $4}' $configpath/config.php) $dbname > $mountpoint/${dbname}.db |
|
41 |
+mysqldump -u sms --password=$(< /home/sms/secret.sms) sms > $mountpoint/sms.db |
|
42 |
+mysqldump -u prosody --password=$(< /home/sms/secret.prosody) prosody > $mountpoint/prosody.db |
|
43 |
+cp -f /home/sms/bot /root/inject $mountpoint |
|
44 |
+ |
|
45 |
+touch $mountpoint/step1 |
|
46 |
+ |
|
47 |
+if ! umount $mountpoint; then |
|
48 |
+ echo "impossible de démonter $mountpoint:" |
|
49 |
+ lsof $mountpoint |
|
50 |
+ exit $umountfailure |
|
51 |
+fi |
|
52 |
+ |
|
53 |
+if ! modprobe -r vboxsf; then |
|
54 |
+ echo "échec du déchargement du module vboxsf" |
|
55 |
+ exit $unloadfailure |
|
56 |
+fi |
|
57 |
+ |
|
58 |
+exit 0 |