At this point , now you have the place (/mnt/databasebkp) to stage your backup images.
5- Know your logical volumes for which, you want to take the backup. In my case I've the volume group "db_sysbkp" (50G) with logical volume "sysbkp" (25G) already . If you don't have logical volume for a volume group you could create like below.
[root@exadb ~]# lvcreate -L 25G -n /dev/db_sysbkp/sysbkp
Logical volume "sysbkp" created
after crating logical volume you could verify the volume group "db_sysbkp" attributes
[root@exadb ~]# vgdisplay db_sysbkp
--- Volume group ---
VG Name db_sysbkp
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 50.00 GB
PE Size 4.00 MB
Total PE 12799
Alloc PE / Size 6400 / 25.00 GB
Free PE / Size 6399 / 25.00 GB
VG UUID OwxfW5-XEY2-BJuP-ylyI-E2AR-d1aG-S3DIdC
6- Once you know the logical volumes to be backed up (eg; sysbkp) , you can create LVM snapshot.
[root@exadb dev]# lvcreate -L5G -s -n syssnap1 /dev/db_sysbkp/sysbkp
Logical volume "syssnap1" created
-L parameter determines the size of the snapshot volume
When the datablocks are modified or deleted after the snapshot is created , the original copy
of the block is written to the snapshot. It is important to size the snapshot sufficiently to store
an original copy of all chaneged blocks. If snapshot runs out of space , it will be deactivated.
From the operating system point of view snapshot will be a block device containing the information from /dev/db_sysbkp/syssnap1 from the moment the snapshot was taken.
[root@exadb dev]# ls d*
dm-0 dm-1 dsp dvd dvd-sr0
db_sysbkp:
sysbkp syssnap1
disk:
by-id by-label by-path by-uuid
[root@exadb dev]#
See the LVM snapshot info
[root@exadb dev]# lvdisplay /dev/db_sysbkp/syssnap1
--- Logical volume ---
LV Name /dev/db_sysbkp/syssnap1
VG Name db_sysbkp
LV UUID rOXrZh-OH6B-Cviy-QuNb-4UTJ-mPxQ-1ddC0J
LV Write Access read/write
LV snapshot status active destination for /dev/db_sysbkp/sysbkp
LV Status available
# open 0
LV Size 25.00 GB
Current LE 6400
COW-table size 5.00 GB
COW-table LE 1280
Allocated to snapshot 0.00%
Snapshot chunk size 4.00 KB
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
7- Mount the snapshot as you would any other file system. First we will create a directory to use as mount point for our snapshot. Then we will mount it.
[root@exadb dev]# mkdir /mnt/snap
[root@exadb ~]# mount /dev/db_sysbkp/syssnap1 /mnt/snap
[root@exadb dev]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
VOBXSHARED on /media/sf_VOBXSHARED type vboxsf (gid=500,rw)
/dev/sr0 on /media/20131031_1914 type iso9660 (ro,nosuid,nodev,uid=0)
/dev/mapper/db_sysbkp-sysbkp on /mnt/sysbkp type ext3 (rw)
/dev/mapper/db_sysbkp-syssnap1 on /mnt/snap type ext3 (rw)
[root@exadb dev]#
[root@exadb /]# lvscan
ACTIVE Original '/dev/db_sysbkp/sysbkp' [25.00 GB] inherit
ACTIVE Snapshot '/dev/db_sysbkp/syssnap1' [5.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [45.03 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [4.84 GB] inherit
Once the snapshot is mounted , we can browse just like any other filesystem. They look and feel
just like the original file system, with one exception that it will not show the files and contents created/modified after the snapshot creation.
8- Test and verify. I created the a text file in the volume (Original) for the test purpose before the snapshot creation with two lines like below. (You should do it just before step 6 )
[root@exadb sysbkp]# echo "First Line" >> /mnt/sysbkp/f1.txt
[root@exadb sysbkp]# echo "Second Line" >> /mnt/sysbkp/f1.txt
[root@exadb sysbkp]# cat /mnt/sysbkp/f1.txt
First Line
Second Line
After creating and mounting the LVM snapshot (Step 6,7) I modified the contents of the file like below
[root@exadb sysbkp]# echo "Third Line - added" >> /mnt/sysbkp/f1.txt
[root@exadb sysbkp]# cat /mnt/sysbkp/f1.txt
First Line
Second Line
Third Line - added
You can see that "Third Line - added" appears in the file (Observe this file is on original volume)
Now check the same file on the LVM snapshot volume
[root@exadb mnt]# cd snap
[root@exadb snap]# ls
f1.txt lost+found
[root@exadb snap]# cat f1.txt
First Line
Second Line
You don't see the "Third Line - added" (Observe this the snapshot volume)
9- After your testing is done and you are comfortable with the results, finally take the backup using tar command.
[root@exadb snap]# cd /mnt/snap
[root@exadb snap]# tar -pjcvf /mnt/sysbkp/exadb_system_backup.tar.bz2 * /boot --exclude /mnt/sysbkp/exadb_system_backup.tar.bz2 >/tmp/exadata_system_backup.stdout 2>/tmp/exadata_system_backup.stderr
Note that /boot file system does not use the LVM for storage. This file system must be backed up using the tar command. That is not the problem, because /boot file system is fairly small and static so I'm not concerned with these files being modified, locked or open during the backup cycle.
10- Unmount the filesystem for snapshot and remove it.
[root@exadb ~]# umount /mnt/snap
[root@exadb ~]# lvremove /dev/db_sysbkp/syssnap1
Do you really want to remove active logical volume syssnap1? [y/n]: y
Logical volume "syssnap1" successfully removed
Note: I've used the example to take the backup for the non-Oracle volume but you can take the Oracle related volumes int he same way.