#!/bin/bash mountpoint=/backup alreadymounted=1 badmodload=2 notmounted=3 umountfailure=4 unloadfailure=5 owncloudpath=/var/www/owncloud datapath=$owncloudpath/data configpath=$owncloudpath/config dbname=owncloud PATH=/usr/sbin:/usr/bin:/sbin:/bin test -d $mountpoint || mkdir $mountpoint if grep -q $mountpoint /proc/mounts; then echo "$mountpoint déjà monté, arrêt" exit $alreadymounted fi if ! test -d /sys/module/vboxsf; then if ! modprobe vboxsf; then echo "module vboxsf non chargé correctement, abandon" exit $badmodload fi fi if ! mount -t vboxsf -o uid=www-data,gid=www-data backup $mountpoint; then echo "impossible de monter $mountpoint" exit $notmounted fi rsync -Avax $configpath $mountpoint/ > /var/log/${0##*/} 2>&1 rsync -Avax --exclude="/etc/ssh/ssh_host_*" /etc $mountpoint/ >> /var/log/${0##*/} 2>&1 rsync -Avax --exclude=lost+found --exclude="data/owncloud.log*" $datapath $mountpoint/ >> /var/log/${0##*/} 2>&1 mysqldump -u owncloud_usr --password=$(awk -F"'" '/dbpassword/{print $4}' $configpath/config.php) $dbname > $mountpoint/${dbname}.db mysqldump -u sms --password=$(< /home/sms/secret.sms) sms > $mountpoint/sms.db mysqldump -u prosody --password=$(< /home/sms/secret.prosody) prosody > $mountpoint/prosody.db cp -f /home/sms/bot /root/inject $mountpoint touch $mountpoint/step1 if ! umount $mountpoint; then echo "impossible de démonter $mountpoint:" lsof $mountpoint exit $umountfailure fi if ! modprobe -r vboxsf; then echo "échec du déchargement du module vboxsf" exit $unloadfailure fi exit 0