#!/bin/bash
# backup.sh DRBD DOMU SNAPSHOT_SIZE VG LVM LVM_SIZE
SMBCLIENT_CONFIG="/etc/xen/scripts/.smbclient"
LOCAL_BACKUP_DIR="/tmp"
DRBD=$1
DOMU=$2
SNAPSHOT_SIZE=$3
VG=$4
LVM=$5
LVM_SIZE=$6
TYPE=$7
DRBD_state=$(echo "$(drbdadm state $DRBD)"|sed -e 's/\/[A-Z][a-z]*//')
if [ $DRBD_state = "Primary" ]; then
lvcreate --size $SNAPSHOT_SIZE --snapshot --name $LVM-snapshot /dev/$VG/$LVM
BACKUP_FILE=$DOMU-$LVM_SIZE-$TYPE.gz
dd if=/dev/$VG/$LVM bs=1024000 | pbzip2 -cf > $LOCAL_BACKUP_DIR/$BACKUP_FILE
lvremove --force /dev/$VG/$LVM-snapshot
smbclient //172.16.0.146/backup -A $SMBCLIENT_CONFIG -c "put $LOCAL_BACKUP_DIR/$BACKUP_FILE /lvm-images/$BACKUP_FILE"
rm $LOCAL_BACKUP_DIR/$BACKUP_FILE
fi
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
#GFS backup strategy
# backup.sh DRBD DOMU SNAPSHOT_SIZE VG LVM LVM_SIZE
00 01 * * * root /etc/xen/scripts/backup.sh xen-drbd-portal portal 3G xen_vg1 portal 30G nightly-`uname -n`
00 02 * * 6 root /etc/xen/scripts/backup.sh xen-drbd-portal portal 3G xen_vg1 portal 30G weekly-`uname -n`
00 03 1 * * root /etc/xen/scripts/backup.sh xen-drbd-portal portal 3G xen_vg1 portal 30G monthly-`uname -n`
00 04 * 1,6 * root /etc/xen/scripts/backup.sh xen-drbd-portal portal 3G xen_vg1 portal 30G archive-`uname -n`-`date +\%m.\%Y`
15 01 * * * root /etc/xen/scripts/backup.sh xen-drbd-ideco xen-drbd-ideco ideco 1G xen_vg2 ideco 4G nightly-`uname -n`
15 02 * * 6 root /etc/xen/scripts/backup.sh xen-drbd-ideco xen-drbd-ideco ideco 1G xen_vg2 ideco 4G weekly-`uname -n`
15 03 1 * * root /etc/xen/scripts/backup.sh xen-drbd-ideco xen-drbd-ideco ideco 1G xen_vg2 ideco 4G monthly-`uname -n`
15 04 * 1,6 * root /etc/xen/scripts/backup.sh xen-drbd-ideco xen-drbd-ideco ideco 1G xen_vg2 ideco 4G archive-`uname -n`-`date +\%m.\%Y`

Комментариев нет:
Отправить комментарий