Backing up Unix LVM volumes

Overview: In the old days computer disks were small compared to the data set sizes that were needed. A solution is to make several physical disks appear virtually (or logically) as a single much larger disk. A large filesystem could then be created on that virtual disk. Later hard disk sizes grew large enough that it made sense to do the opposite: make one physical disk appear as several virtual disks. Each virtual disk holds a filesystem independently of the others. Today such virtual disks are called disk "partitions". Now we have come full circle. Large data warehouse applications require very large filesystems to hold the database data files. To support this sort of application the old idea of combining several disks into one has been resurrected. Novell Netware supported this feature since the 1990s. The physical disk (or selected disk partitions) are formatted to be "physical volume segments". All added physical volume segments become part of a single large virtual disk. The administrator can then create logical "volumes", that is, a filesystem. The exciting part is that if some volume is low on space, you can extend the virtual disk by adding another physical volume segment to it, and then increase the (logical) volume's size. This operation is fast and doesn't disturb the existing data or other partitions (or volumes)! The modern Unix (and Linux) version of this idea is called "Logical Volume Management" (or "LVM"). LVM allows the administrator to • use and allocate disk space more efficiently and flexibly • move logical volumes between different physical devices • have very large logical volumes span a number of physical devices • take snapshots of whole filesystems easily, allowing on-line backup of those filesystems • replace on-line drives without interrupting services Here are step by step instructions of how to take a snapshot and back it up 1. identify the volume ( LV Name ) you would like to backup a. lvdisplay --- Logical volume --- LV Name /dev/VolGroup00/LogVol00 VG Name VolGroup00 LV UUID f1KfeR-oYFX-ZxeT-HKGX-HCAG-1AKU-AaApuZ LV Write Access read/write LV snapshot status source of /dev/VolGroup00/voip_Nov7 [active] LV Status available # open 1 LV Size 72.25 GB Current LE 2312 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:0 2. take the snapshot a. lvcreate --size 32m --snapshot --name voip_Nov7 /dev/VolGroup00/LogVol00 3. Mount the new volume a. mkdir /snap ; mount /dev/VolGroup00/voip_Nov7 /snap 4. back it up using dump a. dump -0u -f /mnt/voip_full_dump_nov4 /snap 5. done You can now unmount the snapshot Notes Taking the snapshot was …a snap Dumping 4.5 GB ( level 0 / full ) took about 20 min on a slow machine and resulted in a 5.2 Gb file Restoring Boot from Knopix live CD Mount the backup hard drive and the new hard drive Mount /dev/sdb1 /backups Mount /dev/sda1 /newroot Restore it using “restore” command Cd /newroot ; restore –rf /backups/voip_full_dump References http://www.howtoforge.com/linux_lvm http://ds9a.nl/lvm-howto/HOWTO//cvs/lvm-howto/output/lvm-howto-7.html http://www.nethamilton.net/docs/dump.html