#!/bin/bash function prep { kvmclient=$1 partition=$2 lvcreate -s /dev/vgserver/${kvmclient} -L 200M -n ${kvmclient}-backup kpartx -a /dev/vgserver/${kvmclient}-backup mount /dev/mapper/vgserver-${kvmclient}--backup${partition} /srv/${kvmclient} } function pop { kvmclient=$1 umount /srv/${kvmclient} kpartx -d /dev/vgserver/${kvmclient}-backup lvremove -f /dev/vgserver/${kvmclient}-backup } function check { c=0 for i in "$@" ; do if [ -z "$(ls -A /srv/$i 2>/dev/null)" ]; then c=1 echo WARNING: Abbruch, weil /srv/$i leer erscheint fi done [ $c -eq 1 ] && return 1 || return 0 } prep ipfire 1 prep chapman 1 # check for empty dirs check ipfire chapman # backup using rsnapshot if [ $? -eq 0 ]; then rsnapshot daily fi # normalzustand herstellen pop chapman pop ipfire