fs-snapshot plugin: add included_vgs and excluded_vgs options to [lvm] section

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've been testing yum-plugin-fs-snapshot with LVM snapshots. All test worked find but I missed a functionality. Tipically, OS and application data are located in separated Volume Groups and most times, when I update or install software with yum, I'll only want to get snapshots of the OS logical volumes, not data ones. In this case the only available option "exclude" can be difficult to manage (I may have many data filesystems) and a "include only a specific VG" option would be convenient. I've created following patch to implement "included_vgs" and "excluded_vgs" options in the lvm section of fs-snapshot.conf file:

-If included_vgs option exists, only the logical volumes included in those volume groups are snapshoted. -If excluded_vgs option exists, all logical volumes but those in the specified volume groups are snapshoted.


diff --git a/plugins/fs-snapshot/fs-snapshot.py b/plugins/fs-snapshot/fs-snapshot.py
index 5094881..71caa3c 100644
--- a/plugins/fs-snapshot/fs-snapshot.py
+++ b/plugins/fs-snapshot/fs-snapshot.py
@@ -102,6 +102,25 @@ def inspect_volume_lvm(conduit, volume):
"kernel doesn't support snapshot-merge" % device)
             return 0
         volume[lvm_key] = 1
+
+    # Check if include_vgs is defined in [lvm] section.
+    # If so, we compare VG name with include_vgs list
+
+ included_vgs = conduit.confString('lvm', 'included_vgs', default="").split()
+    if len(included_vgs) > 0:
+       vg = device.split("/")[2]
+        if vg not in included_vgs :
+           return 0
+
+    # Check if excluded_vgs is defined in [lvm] section.
+    # If so, we compare VG name with excluded_vgs list
+
+ excluded_vgs = conduit.confString('lvm', 'excluded_vgs', default="").split()
+    if len(excluded_vgs) > 0:
+        vg = device.split("/")[2]
+        if vg in excluded_vgs :
+            return 0
+
     return 1

 def inspect_volume(conduit, volume):


And updated man page:

diff --git a/docs/yum-fs-snapshot.conf.5 b/docs/yum-fs-snapshot.conf.5
index a4b4f02..496cfc7 100644
--- a/docs/yum-fs-snapshot.conf.5
+++ b/docs/yum-fs-snapshot.conf.5
@@ -29,6 +29,16 @@ created for filesystems built on LVM logical volumes.
 This is the space delimited lvcreate argument list that is used to
 specify the size of the snapshot LV.  Valid lvcreate size options are -l
 or -L.  If not specified then LVM snapshots will not be created.
+.SH OPTION - [lvm] section
+.IP included_vgs
+This is a space delimited list of the LVM Volume Groups you wish to have
+snapshoted by this plugin. When this option is used, all volume groups not
+listed are implicitely excluded.
+.SH OPTION - [lvm] section
+.IP excluded_vgs
+This is a space delimited list of the LVM Volume Groups you don't wish to have
+snapshoted by this plugin. When this option is used, all volume groups not
+listed are automatically included.
 .SH AUTHOR
 .RS
 Josef Bacik <josef@xxxxxxxxxxxxxx>


I've tested it in a RHEL6 systems and It seems to be working as expected.

Best regards,

Alfredo
_______________________________________________
Yum mailing list
Yum@xxxxxxxxxxxxxxxxx
http://lists.baseurl.org/mailman/listinfo/yum


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux