Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 12th August 2009, 19:42
atjensen11 atjensen11 is offline
Senior Member
 
Join Date: Dec 2007
Posts: 199
Thanks: 9
Thanked 6 Times in 6 Posts
Default Backing up Xen DomUs - NFS vs. LVM Snapshots

I am looking for input regarding how to backup DomU machine filesystems.

My system is a Debian Lenny Dom0. All DomUs to date are Debian Lenny as well. All DomUs are backed by LVM.

Initially, because of the use of LVM, I had planned to conduct backups from the Dom0 to an externally attached eSATA drive using LVM snapshots. However, recent discussion on the Xen mailing lists have caused me to question this approach. The discussion focussed mainly on the inability of snapshots to backup data that is in cache at the time the snapshot is created.

This has led me to consider making an NFS server DomU. I would plan on backing the "disks" in the DomU with either LVM partitions or by passing the physical disk of the eSATA external drive. Then I would modify the DomU Xen config files to mount the NFS shares to accomplish the backup. The backups would be done at the DomU level in this configuration over the virtualized network to the NFS server.

I would like to get some input on which approach may be better. Not of my systems are highly mission critical. They are however, highly utilized and would cause a great deal of stress on my behalf if they weren't easily brought back online.

Are there backup configurations that I haven't considered to date that may be better than the two approaches above?
Reply With Quote
Sponsored Links
  #2  
Old 19th August 2009, 12:01
matey matey is offline
Member
 
Join Date: Feb 2009
Posts: 93
Thanks: 13
Thanked 3 Times in 3 Posts
Default

we also use lvm and rsnapshot (uses rsync) along with cron to do our xen (domu) backups.
if you need to I can post our scripts.
Reply With Quote
  #3  
Old 19th August 2009, 19:21
atjensen11 atjensen11 is offline
Senior Member
 
Join Date: Dec 2007
Posts: 199
Thanks: 9
Thanked 6 Times in 6 Posts
Default

I just ran across some rsync snapshot articles yesterday and thought it would suit my needs.

If you are willing, I would be very interested in seeing your scripts.
Reply With Quote
  #4  
Old 20th August 2009, 12:29
matey matey is offline
Member
 
Join Date: Feb 2009
Posts: 93
Thanks: 13
Thanked 3 Times in 3 Posts
Default

Cool, I have to post a couple bcs in one script it refers to another ;
This is a Daily script;

#!/bin/bash

DIR=/root/backup
BACKUP_CMD=backup-lv.sh

VG=/dev/vg1 #whichever folder your xen files located at)
LV[0]=xen-1 # (name of diff, xen machines/guests)
LV[1]=xen-2
LV[2]=xen2-data #xen2 is a web server with large amount of data
LV[3]=xen-3

cd $DIR
COUNT=0
CAT_STR=""
while [ $COUNT -lt ${#LV[@]} ]
do
./$BACKUP_CMD $VG/${LV[$COUNT]} &> last-backup-${LV[$COUNT]}
CAT_STR="${CAT_STR} last-backup-${LV[$COUNT]}"
MOO=$((COUNT++))
done

ls -lh /mnt/system_backups/ &> last-backup-ls
cat $CAT_STR last-backup-ls > last-backup.txt
echo "daily backup report attached" | mutt -s "$HOSTNAME daily backup report" -a last-backup.txt MyEmail@MyCompany.com
__________________________________________________ ____________________________________

This is backup-lv.sh

#!/bin/bash

LV=$1

export PATH=$PATH:/sbin

echo Backing up $LV...
if ! [ -e $LV ]; then
echo ' ...No such device exists!'
exit 1
fi

NAME=`expr "$LV" : ".*\/\(.*\)$"`
NAME_SNAP=${NAME}_snap
LV_SNAP=${LV}_snap

/etc/init.d/udev restart
sleep 120
echo ' ...Creating snapshot'
lvcreate -s -n${NAME_SNAP} -L1024 $LV
RV=$?
while [ $RV -gt 0 ]
do
lvremove -f ${LV_SNAP}
sleep 120
lvcreate -s -n${NAME_SNAP} -L1024 $LV
RV=$?
done
mkdir -p /mnt/${NAME_SNAP}
echo ' ...Mounting snapshot'
mount ${LV_SNAP} /mnt/${NAME_SNAP}
cd /mnt/${NAME_SNAP}/
echo ' ...Creating archive'
tar czf /mnt/system_backups/${NAME}.tgz *
cd /
echo ' ...Unmounting and removing snapshot'
umount /mnt/${NAME_SNAP}
lvremove -f ${LV_SNAP}
echo ' All done!'
echo
sleep 120

--------------------------------------------------------------------------------------------------------

This is lv-rsync.sh

#!/bin/bash

LV=$1

export PATH=$PATH:/sbin

echo Backing up $LV...
if ! [ -e $LV ]; then
echo ' ...No such device exists!'
exit 1
fi

NAME=`expr "$LV" : ".*\/\(.*\)$"`
NAME_SNAP=${NAME}_snap
LV_SNAP=${LV}_snap

/etc/init.d/udev restart
sleep 121
echo ' ...Creating snapshot'
lvcreate -s -n${NAME_SNAP} -L1024 $LV
RV=$?
while [ $RV -gt 0 ]
do
lvremove -f ${LV_SNAP}
sleep 121
lvcreate -s -n${NAME_SNAP} -L1024 $LV
RV=$?
done
mkdir -p /mnt/${NAME_SNAP}
echo ' ...Mounting snapshot'
mount ${LV_SNAP} /mnt/${NAME_SNAP}
echo ' ...rsyncing'
rsync -avz --delete -e "ssh" /mnt/${NAME_SNAP}/* 192.168.1.10:/mnt/${NAME}/ #Or whatever IP ?DNS Name??
#cd /mnt/${NAME_SNAP}/
#echo ' ...Creating archive'
#tar czf /mnt/system_backups/${NAME}.tgz *
#cd /
echo ' ...Unmounting and removing snapshot'
umount /mnt/${NAME_SNAP}
lvremove -f ${LV_SNAP}
echo ' All done!'
echo
sleep 120

----------------------------------------------------------------------------------------------------------

This one is a general backup script

#!/bin/sh
tar czvf $1.$(date +%Y%m%d-%H%M%S).tgz $1
exit $?

I call it backit and do like
./backit /directory_name
it will create a .year.month.day-hour.minute.sec.tgz file
but since it starts with a dot . it may be hidden in some systems
ls -a or take out the dot

Last edited by matey; 20th August 2009 at 12:32.
Reply With Quote
  #5  
Old 20th August 2009, 18:18
matey matey is offline
Member
 
Join Date: Feb 2009
Posts: 93
Thanks: 13
Thanked 3 Times in 3 Posts
 
Default

I found some interesting articles on mirroring servers;
They use apt-mirror in Debian/Ubuntu by apt-get install in here;
http://www.packtpub.com/article/crea...ror-apt-cacher

This link shows how to create quick virtual machines?
If anyone has any experience with these (juice-vm/debmirror) please share:

https://help.ubuntu.com/community/JeOSVMBuilder

https://help.ubuntu.com/community/Debmirror

In any case I am told to make a backup copy of our main server which is off site and cannot be reached physically, so I have another machine here which is not similar (less ram diff. hard drive config, etc, etc,) and it is running Hardy whereas our off site server is running Feisty so I am not so sure how I could make an exact copy of the off site server (in case it went down this one will take over)? Plus pulling all the data/the OS would slow our already slow network down to halt!

Any ideas, info would be appreciated!
PS right now I am using those scripts do to the backups but if the main server goes out the backup files go with it cuz they are getting stored in there. Plus we have 4 Xen machines running off that 1 off-site server and our web site is in one of those xen machines...


BTW I forgot to post a weekly backup script:

################################################## #####################################
#!/bin/bash

keychain id_rsa
. ~/.keychain/$HOSTNAME-sh

DIR=/root/backup
BACKUP_CMD=backup-lv-rsync.sh

VG=/dev/vg1 ###(This is where the xen files/volumes/machines reside)
LV[0]=xen-1 ###(These are the names of different xen guest machines)
LV[1]=xen-2
LV[2]=xen-2_data ###(split this one xen-2 machine into 2 since has a large data stored)
LV[3]=xen-3

cd $DIR
COUNT=0
CAT_STR=""
while [ $COUNT -lt ${#LV[@]} ]
do
./$BACKUP_CMD $VG/${LV[$COUNT]} &> last-backup-${LV[$COUNT]}
CAT_STR="${CAT_STR} last-backup-${LV[$COUNT]}"
MOO=$((COUNT++))
done

ls -lh /mnt/system_backups/ &> last-backup-ls
cat $CAT_STR last-backup-ls > last-backup.txt
echo "weekly backup report attached" | mutt -s "$HOSTNAME weekly backup report" -a last-backup.txt admin@MyCompany.com
----------------------------------------------------------------------------------------------------------------------------------------------------------------

crontab -e

# m h dom mon dow command
01 05 * * 1,2,3,4,5,6 /root/backup/backup-daily.sh
01 05 * * 7 /root/backup/backup-weekly.sh

Last edited by matey; 20th August 2009 at 18:56.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 8.04 LTS - RAID 1 + LVM + XEN atjensen11 HOWTO-Related Questions 1 20th January 2009 20:35
Centos5 - Xen - DomU with LVM jgijsen HOWTO-Related Questions 2 27th February 2008 11:57
CentOS Xen local NFS mount? unclecameron HOWTO-Related Questions 8 7th February 2008 17:47
The Perfect Xen 3.0 Setup For Debian - Root-NFS: No NFS server available, giving up. finn HOWTO-Related Questions 13 7th November 2006 17:51
Xen: Smp & Lvm zokahn HOWTO-Related Questions 5 27th January 2006 10:28


All times are GMT +2. The time now is 13:27.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.