Understand the snapshot process
Hi,
I'm using LVM under SuSE Linux 8.0, and I don't understand all the snapshot process.
I know a snapshot is an exact copy of an existing volume :o)
Our config is :
2 disks 73 Go RAID 1
--> 1 VG "OVG" (60 GB)
--> 1 LV /dev/OVG/data (40 GB) mounted on /share/data
To create a snapshot whith ReiserFS, we do this (I'm following the LVM How-To) :
Tux :# lvcreate -L30G -s -n snap_admin /dev/OVG/data
and so, we mount the snapshot :
Tux :# mount /dev/OVG/snap_admin /share/snapshot
At this point, the /share/snapshot contain a copy of the /share/data directory.
The How To say "Do the backup" for exemple with tar.
My question is : Why we must to copy the data with a system command on the snapshot ? Is a "create snapshot/remove snapshot" not possible ?
Thanks in advnace for your response.
--
Jean Marie Ari�s
Quoted 15 lines · Jean Marie Ariès
Hi,
I'm using LVM under SuSE Linux 8.0, and I don't understand all the snapshot process.
Our config is :
2 disks 73 Go RAID 1
--> 1 VG "OVG" (60 GB)
--> 1 LV/dev/OVG/data(40 GB) mounted on /share/dataTo create a snapshot with ReiserFS, we do this:
Tux :# lvcreate -L30G -s -nsnap_admin/dev/OVG/data
and so, we mount the snapshot :
Tux :# mount/dev/OVG/snap_admin/share/snapshot
Quoted 7 lines
At this point, the /share/snapshot contain a copy of the /share/data directory.
The How To say "Do the backup" for exemple with tar.
My question is : Why we must to copy the data with a system command on the snapshot ? Is a "create snapshot/remove snapshot" not possible ?
Jean Marie,
The snapshot is useful for narrowing a backup window, but is not useful as a backup.
In other words, a backup can take hours while a snapshot takes seconds. This is possible because the snapshot creation process does not copy your data; it simply sets up a process that will track any future changes.
Once you've created a snapshot, you can go back to work (restart your database, for example). The data in the original LV (/dev/OVG/data) will change, but the data in /share/snapshot won't. Once you've copied /share/snapshot/ somewhere safe, you remove the snapshot with lvremove. The How-To suggests tar, but other commands are possible.
Why not leave the snapshot in place all the time? Well, there are three reasons.
1) As long as the snapshot exists, writes to /dev/OVG/data will be slower than usual because they have to be done twice (once to record the new data in /dev/OVG/data, once to record the changes in /dev/OVG/snap_admin).
2)If you leave a snapshot in place long enough, it will run out of space to store the changes; once this happens, your snapshot is useless. In the example you gave, you can make roughly 30GB worth of changes before the snapshot fills up. You can extend the snapshot to the size of the original lv (40GB) but not beyond.
3) If the disk drive fails, both the original LV and the snapshot will be lost.
I hope my explanation is clear and correct. If not, somebody please let me know ;-)
Signature · 2 lines
David Johnston <[email protected]> Little Bald Consulting, LLC
Great !
Your explanation is perfect :o)
So, I understand better the use of a snapshot.
The /data contains files sharing with Samba. So, I think I can do one snapshot per day at midnight, and remove it immediatly. If I have to restore data for the snapshot, its's alway possible to mount the /dev/OVG/snap_admin ?
Thanks in advance and happy new year !
David Johnston a �crit :
Quoted 62 lines · Jean Marie Ari�s
Quoted 15 lines
Hi,
I'm using LVM under SuSE Linux 8.0, and I don't understand all the snapshot process.
Our config is :
2 disks 73 Go RAID 1
--> 1 VG "OVG" (60 GB)
--> 1 LV/dev/OVG/data(40 GB) mounted on /share/dataTo create a snapshot with ReiserFS, we do this:
Tux :# lvcreate -L30G -s -nsnap_admin/dev/OVG/data
and so, we mount the snapshot :
Tux :# mount/dev/OVG/snap_admin/share/snapshotQuoted 7 lines
At this point, the /share/snapshot contain a copy of the /share/data directory.
The How To say "Do the backup" for exemple with tar.
My question is : Why we must to copy the data with a system command on the snapshot ? Is a "create snapshot/remove snapshot" not possible ?
Jean Marie,
The snapshot is useful for narrowing a backup window, but is not useful as a backup.In other words, a backup can take hours while a snapshot takes seconds. This is possible because the snapshot creation process does not copy your data; it simply sets up a process that will track any future changes.
Once you've created a snapshot, you can go back to work (restart your database, for example). The data in the original LV (
/dev/OVG/data) will change, but the data in /share/snapshot won't. Once you've copied /share/snapshot/ somewhere safe, you remove the snapshot with lvremove. The How-To suggests tar, but other commands are possible.Why not leave the snapshot in place all the time? Well, there are three reasons.
1) As long as the snapshot exists, writes to
/dev/OVG/datawill be slower than usual because they have to be done twice (once to record the new data in/dev/OVG/data, once to record the changes in/dev/OVG/snap_admin).2)If you leave a snapshot in place long enough, it will run out of space to store the changes; once this happens, your snapshot is useless. In the example you gave, you can make roughly 30GB worth of changes before the snapshot fills up. You can extend the snapshot to the size of the original lv (40GB) but not beyond.
3) If the disk drive fails, both the original LV and the snapshot will be lost.
I hope my explanation is clear and correct. If not, somebody please let me know ;-)
--
David Johnston <[email protected]>
Little Bald Consulting, LLC
Quoted 5 lines
_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
--
Sinc�rement,
Jean Marie Ari�s
Imprimeries IPS
Responsable Syst�mes/R�seaux
Quoted 10 lines · Jean Marie Ariès
Great !
Your explanation is perfect :o)
So, I understand better the use of a snapshot.
The /data contains files sharing with Samba. So, I think I can do one snapshot per day at midnight, and remove it immediatly. If I have to restore data for the snapshot, its's alway possible to mount the
/dev/OVG/snap_admin?
Jean Marie,
I'm not sure I understand what you accomplish this way. Do you mean to say that you would remove yesterday's snapshot and create a new one at midnight each night? This protects you from accidents ("rm -f /data") but not from someone who needs last Friday's version of a file.
If you need the data in the snapshot, you need to put it somewhere safe.
To summarize:
1. Unmount /data
2. Make the snapshot
3. Remount /data
4. Mount the snapshot
5. Back up the snapshot (copy the data to tape, cd, whatever)
6. Unmount the snapshot
7. Remove the snapshot
-David
Signature · 2 lines
David Johnston <[email protected]> Little Bald Consulting, LLC
Ok. In other sentence, the life of the snapshot is the time between the lvcreate -s and the lvremove command. The data must be saved if we need old files.
So the snapshot is only a good solution to backup the data update every time ?
David Johnston a �crit :
Quoted 34 lines · Jean Marie Ari�s
Quoted 10 lines
Great !
Your explanation is perfect :o)
So, I understand better the use of a snapshot.
The /data contains files sharing with Samba. So, I think I can do one snapshot per day at midnight, and remove it immediatly. If I have to restore data for the snapshot, its's alway possible to mount the
/dev/OVG/snap_admin?Jean Marie,
I'm not sure I understand what you accomplish this way. Do you mean to say that you would remove yesterday's snapshot and create a new one at midnight each night? This protects you from accidents ("rm -f /data") but not from someone who needs last Friday's version of a file.If you need the data in the snapshot, you need to put it somewhere safe.
To summarize:
1. Unmount /data
2. Make the snapshot
3. Remount /data
4. Mount the snapshot
5. Back up the snapshot (copy the data to tape, cd, whatever)
6. Unmount the snapshot
7. Remove the snapshot-David
--
David Johnston <[email protected]>
Little Bald Consulting, LLC
Quoted 5 lines
_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
--
Sinc�rement,
Jean Marie Ari�s
Imprimeries IPS
Responsable Syst�mes/R�seaux