#!/bin/bash REMOTE_RSYNC=root@se.imbg.org.ua::OWNCLOUD LOCAL_MOUNT=/dev/shm/owncloud-backup LOCAL_LV=/dev/owndata/data BACKUP_PATH=/root/backup LOCK_FILE=/var/lock/owncloud-rsync [ -f "$LOCK_FILE" ] && exit 0 trap "rm -f $LOCK_FILE" EXIT SIGINT SIGTERM touch "$LOCK_FILE" source "${BACKUP_PATH}/libbackup.sh" if ! check_lvm "$LOCAL_LV"; then echo "Cannon find logical volume $LOCAL_LV. Exiting" exit 1 fi lv_snap=$( get_lvm_snapshot "$LOCAL_LV" 100 ) mkdir -p "$LOCAL_MOUNT" mount -oro "$lv_snap" "$LOCAL_MOUNT" do_rsync "$LOCAL_MOUNT" "$REMOTE_RSYNC" if [ $? -ne 0 ]; then echo "Failed to rsync data. Turning on verbosity to catch the error" export RSYNC_VERBOSE=1 do_rsync "$LOCAL_MOUNT" "$REMOTE_RSYNC" fi umount "$lv_snap" remove_lvm_snapshot "$lv_snap"