{"id":426,"date":"2014-10-06T18:28:16","date_gmt":"2014-10-06T18:28:16","guid":{"rendered":"https:\/\/www.nicktailor.com\/?p=426"},"modified":"2022-10-21T11:53:08","modified_gmt":"2022-10-21T11:53:08","slug":"how-to-do-a-full-restore-if-you-wiped-all-your-lvms","status":"publish","type":"post","link":"https:\/\/nicktailor.com\/tech-blog\/how-to-do-a-full-restore-if-you-wiped-all-your-lvms\/","title":{"rendered":"How to do a full restore if you wiped all your LVM&#8217;s"},"content":{"rendered":"<p>I\u2019m sure some of you have had the wonderful opportunity to experience loosing all your LVM info in error. Well all is not lost and there is hope. I will show ya how to restore it.<\/p>\n<p>The beauty of LVM is that is naturally creates a backup of the Logical Volumes in the following location.<\/p>\n<ul>\n<li><strong><em>\/etc\/lvm\/archive\/<\/em><\/strong><\/li>\n<\/ul>\n<p>Now If you had just wiped out your LVM and it was simply using one physical disk for all your LVM\u2019s you could simply do a full restore doing the following.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>vgcfgrestore -f \/etc\/lvm\/archive\/(volumegroup to restore) (destination&nbsp;<\/strong><strong>volumegroup)<br \/>\n<\/strong><strong>o&nbsp;&nbsp;&nbsp; (ie.)vgcfgrestore -f \/etc\/lvm\/archive\/vg_dev1_006.000001.vg vg_dev<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>If you had multiple disks attached to your volume group then you need to do a couple more things to be able to do a restore.<\/p>\n<ul>\n<li>Cat the file <em>\/etc\/lvm\/archive\/whatevervolumgroup.vg<\/em> file you should see something like below<\/li>\n<\/ul>\n<ul>\n<li><em>physical_volumes {<\/em><\/li>\n<\/ul>\n<p><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pv0 {<\/em><\/p>\n<p><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id = &#8220;ecFWSM-OH8b-uuBB-NVcN-h97f-su1y-nX7jA9&#8221;<br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; device = &#8220;\/dev\/sdj&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Hint only<\/em><em><br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; status = [&#8220;ALLOCATABLE&#8221;]<br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flags = []<br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dev_size = 524288000&nbsp;&nbsp;&nbsp; # 250 Gigabytes<br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pe_start = 2048<br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pe_count = 63999&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # 249.996 Gigabytes<br \/>\n<\/em><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>You will need to recreate all the physical volume UUID inside that .vg file for volume group to be able to restore.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong><em>pvcreate \u2013restore \/etc\/lvm\/archive\/vgfilename.vg \u2013uuid &lt;UUID&gt; &lt;DEVICE&gt;<br \/>\n<\/em><em><br \/>\n<\/em><\/strong><strong>o&nbsp;<em>(IE) pvcreate &#8211;restorefile \/etc\/lvm\/archive\/vg_data_00122-1284284804.vg &#8211;uuid ecFWSM-OH8b-uuBB-NVcN-h97f-su1y-nX7jA9 \/dev\/sdj<\/em><\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>Repeat this step for all the physical volumes in the archive vg file until they have all been created.<\/li>\n<\/ul>\n<p>Once you have completed the above step you should now be able to restore your voluegroups that were wiped<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>vgcfgrestore -f \/etc\/lvm\/archive\/(volumegroup to restore) (destination volumegroup)<br \/>\n<\/strong><strong><br \/>\no (ie.)vgcfgrestore -f \/etc\/lvm\/archive\/vg_dev1_006.000001.vg vg_dev<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>Running the command <strong><em>vgdisplay<\/em><\/strong> and <em><strong>pvdisplay<\/strong><\/em> should show you that everything is back the way it should be<\/li>\n<\/ul>\n<p>If you have questions email nick@nicktailor.com<\/p>\n<p>Cheers<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019m sure some of you have had the wonderful opportunity to experience loosing all your LVM info in error. Well all is not lost and there is hope. I will show ya how to restore it. The beauty of LVM is that is naturally creates a backup of the Logical Volumes in the following location. \/etc\/lvm\/archive\/ Now If you had<a href=\"https:\/\/nicktailor.com\/tech-blog\/how-to-do-a-full-restore-if-you-wiped-all-your-lvms\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,125,138,29],"tags":[],"class_list":["post-426","post","type-post","status-publish","format-standard","hentry","category-centos","category-diskstuff","category-linux","category-logical-volumes"],"_links":{"self":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/comments?post=426"}],"version-history":[{"count":17,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/426\/revisions"}],"predecessor-version":[{"id":1614,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/426\/revisions\/1614"}],"wp:attachment":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/media?parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/categories?post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/tags?post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}