carlopmart
2008-May-16 12:50 UTC
[CentOS] OT: Building NFS server with LVM and snapshots enabled
Hi all, I need to build a NFS CentOS 5.1 based server with LVM and snaphosts for disaster recovering to serve storage to three ESX servers for a development dept. I have 500 GB for storage. Data that I need to store on this server is 150 GB and can grow to 210 GB to the end of year ... My questions are: - Is it possible to do some type of scripting to do data snapshots every day and then copy to a remote server?? Some example, please?? - How can I restore snapshot data on the production server if I need to recover it?? Openfiler or FreeNAS isn't an option to do this task (customer requeriment). -- CL Martinez carlopmart {at} gmail {d0t} com
Fajar Priyanto
2008-May-16 15:37 UTC
[CentOS] OT: Building NFS server with LVM and snapshots enabled
On Friday 16 May 2008 19:50:37 carlopmart wrote:> - Is it possible to do some type of scripting to do data snapshots every > day and then copy to a remote server?? Some example, please?? > - How can I restore snapshot data on the production server if I need to > recover it?? > Openfiler or FreeNAS isn't an option to do this task (customer > requeriment).This is a script to backup LVM using snapshot from Zimbra. Pls take a look at it and you can easily adjust it to your needs. http://www.arinet.org/zimbra-backup-lvm.sh.txt HTH, -- Fajar Priyanto | Reg'd Linux User #327841 | Linux tutorial http://linux2.arinet.org 22:32:39 up 39 min, 2.6.22-14-generic GNU/Linux Let's use OpenOffice. http://www.openoffice.org The real challenge of teaching is getting your students motivated to learn. -------------- next part -------------- A non-text attachment was scrubbed... Name: zimbra-backup-lvm.sh Type: application/x-shellscript Size: 2003 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20080516/a32e35bb/attachment-0005.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. URL: <http://lists.centos.org/pipermail/centos/attachments/20080516/a32e35bb/attachment-0005.sig>
Theo Band
2008-May-19 17:46 UTC
[CentOS] OT: Building NFS server with LVM and snapshots enabled
carlopmart wrote:> Hi all, > > I need to build a NFS CentOS 5.1 based server with LVM and snaphosts > for disaster recovering to serve storage to three ESX servers for a > development dept. I have 500 GB for storage. Data that I need to store > on this server is 150 GB and can grow to 210 GB to the end of year ... > > My questions are: > > - Is it possible to do some type of scripting to do data snapshots > every day and then copy to a remote server?? Some example, please??Yes of course. I would suggest to use rsync for that, see the example below. I have experimented in the past with multiple snapshots a day over a week for users home space. The snapshots gave users a way to quickly retrieve lost data. Drawback is that snapshots tend to slow down the file server (it freezes temporarily to update the snaphot). A temporary snapshot during backup works OK.> > - How can I restore snapshot data on the production server if I need > to recover it??Most easy way would be to make a snapshot and make this snapshot the active disk. If you need to revert, just remove the snapshot and create a new one from the original unmodified data. But since you want to use NFS, you will have to reboot to free up the snapshot which is not so nice. The other way around is also possible. Just rsync the source NFS disk from the snapshot. Again I would only make a snapshot temporarily and use it to make a copy (or sync) to a second file system. This second file system can than be setup with multiple snapshots over time. This prevents the slowdown of the "main" file server. If you need to revert you can use rsync again. (rsync works incrementally so it safes a lot of time if most data is still the same) Example script to run with crontab to synchronize multiple volumes to a backup server: date +"$0 started: %x %T" PATH=$PATH:/usr/sbin volumes="vola volb volc vold" for i in $volumes do # Create a new snapshot # Maximum snapshot size 7G DATE=$(date +%a_%y%m%d_%H%M) lvcreate --size 10G -n ${i}_${DATE} --permission r --snapshot /dev/VolGroup00/$i # Mount the snapshot mkdir -p /snapshot/${DATE}/$i mount -o ro /dev/VolGroup00/${i}_${DATE} /snapshot/${DATE}/$i rsync -aq --delete /snapshot/${DATE}/$i/ remote_host:/mnt/$i/ umount /snapshot/${DATE}/$i rmdir /snapshot/${DATE}/$i rmdir /snapshot/${DATE} lvremove -f /dev/VolGroup00/${i}_${DATE} done date +"$0 finished: %x %T" You could create daily snapshots on the remote server as well. I use (incremental) dump and restore for that. Cheers, Theo