{"id":2416,"date":"2016-07-07T22:21:16","date_gmt":"2016-07-07T10:21:16","guid":{"rendered":"http:\/\/www.zoyinc.com\/?p=2416"},"modified":"2023-05-28T16:39:56","modified_gmt":"2023-05-28T04:39:56","slug":"backing-up-open-media-vault","status":"publish","type":"post","link":"http:\/\/www.zoyinc.com\/?p=2416","title":{"rendered":"Backing up Open Media Vault"},"content":{"rendered":"<p>Backing up OMV can be a challenge as it doesn&#8217;t have any backup functionality. While there are solutions like Clonezilla and rsync the simplest is &#8220;dd&#8221; or &#8220;dcfldd&#8221;. You should read the article <a  href=\"http:\/\/www.zoyinc.com\/?p=2381\">Installing Open Media Vault<\/a> which explains how I suggest you do it so you don&#8217;t have to backup a 250GB hard drive.<\/p>\n<p>This post describes backing up and restoring in a scenario where OMV is installed to a very small, 7GB, portion of the system disk. Again the article\u00a0<a  href=\"http:\/\/www.zoyinc.com\/?p=2381\">Installing Open Media Vault<\/a> describes this approach in more detail<\/p>\n<h2>Before you start<\/h2>\n<p>Before you do anything I would suggest you remove any drives you don&#8217;t need. So if restoring from RAID then obviously you need the RAID disks. But if you are restoring from a network share then all you need is the system disk connected. It&#8217;s just about being extra careful that you don&#8217;t accidentally wipe over the wrong thing.<\/p>\n<p>For this exercise we will boot from a Debian USB so follow the instructions in the post <a  href=\"http:\/\/www.zoyinc.com\/?p=2353\">Create a Debian Live USB flash drive<\/a><\/p>\n<p>We are going to use &#8220;dcfldd&#8221; so you should install it:<\/p>\n<pre class=\"crayon:false;\">apt-get install dcfldd<\/pre>\n<p>Note the above might appear to hang on &#8220;processing triggers for man-db&#8221;, just be patient it might take a minute or so.<\/p>\n<h3>Wipe the disk first<\/h3>\n<p>Sometimes its a good idea to wipe out the new disk first, if you want to do this follow the instructions in the post\u00a0Wipe a RAID disk.<\/p>\n<p>First work out which disk needs to be wiped by running &#8220;lsblk&#8221;:<\/p>\n<pre class=\"crayon:false;\">root@debian:~# lsblk\nNAME\u00a0\u00a0 MAJ:MIN RM\u00a0 SIZE RO TYPE MOUNTPOINT\nsda\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 1\u00a0 7.5G\u00a0 0 disk\n\u2514\u2500sda1\u00a0\u00a0 8:1\u00a0\u00a0\u00a0 1\u00a0 1.2G\u00a0 0 part \/lib\/live\/mount\/medium\nsdb\u00a0\u00a0\u00a0\u00a0\u00a0 8:16\u00a0\u00a0 0 55.9G\u00a0 0 disk\n\u251c\u2500sdb1\u00a0\u00a0 8:17\u00a0\u00a0 0 53.6G\u00a0 0 part\n\u251c\u2500sdb2\u00a0\u00a0 8:18\u00a0\u00a0 0\u00a0\u00a0\u00a0 1K\u00a0 0 part\n\u2514\u2500sdb5\u00a0\u00a0 8:21\u00a0\u00a0 0\u00a0 2.3G\u00a0 0 part\nloop0\u00a0\u00a0\u00a0 7:0\u00a0\u00a0\u00a0 0\u00a0 1.1G\u00a0 1 loop \/lib\/live\/mount\/rootfs\/filesystem.squashfs<\/pre>\n<p>From the above you can see sda is the Debian Live USB key and loop is part of this.<\/p>\n<p>Thus we can see that sdb with 3 partitions is the system drive. If you want to zero the entire drive drive as well to reduce your backup sizes then run the following:<\/p>\n<pre class=\"crayon:false;\">dcfldd if=\/dev\/zero of=\/dev\/sdb<\/pre>\n<p>Giving you something like:<\/p>\n<pre class=\"crayon:false;\">root@debian:~# dcfldd if=\/dev\/zero of=\/dev\/sdb\n47616 blocks (1488Mb) written.<\/pre>\n<p>And results in<\/p>\n<pre class=\"crayon:false;\">root@debian:~# dcfldd if=\/dev\/zero of=\/dev\/sdb\n2441984 blocks (76312Mb) written.\n2442211+0 records in\n2442210+0 records out<\/pre>\n<p>If you wanted to zero a smaller section of the disk you would run something like:<\/p>\n<pre class=\"crayon:false; \">dcfldd if=\/dev\/zero of=\/dev\/sdb bs=512 count=15682111<\/pre>\n<p>This will zero 15682111 sectors each sector being 512 bytes<\/p>\n<p>Mount the restore location<\/p>\n<p>Now make the image restore\/backup accessible.<\/p>\n<h3>Backup to a shared network drive<\/h3>\n<p>If the backup image is on a shared network drive then map this to a mount point:<\/p>\n<pre class=\"crayon:false;\">mkdir \/nas1\nmount -t cifs -o username=joe,password=joesPassword \/\/192.168.202.44\/sata1 \/nas1\ncd \/nas1<\/pre>\n<p>If you get an error &#8220;Host is down&#8221; you might need to add &#8220;vers=1.0&#8221; or similar. This would give:<\/p>\n<pre>mount -t cifs -o vers=1.0,username=joe,password=joesPassword \/\/192.168.202.44\/sata1 \/nas1<\/pre>\n<h3>Backup to a local RAID array<\/h3>\n<p>If the backup image is on the RAID drive for OMV then you need to first install the mdadm packages:<\/p>\n<pre class=\"crayon:false;\">apt-get install mdadm rsync initramfs-tools<\/pre>\n<p>During the install it will ask about &#8220;Configuring mdadm&#8221; and will ask about &#8220;MD arrays needed for the root file system&#8221;. You need to enter &#8220;none&#8221; as your answer and click &lt;enter&gt;.<\/p>\n<p>There is another issue at this point and that is if the terminal window, Putty say, is too small then all you see will be:<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2424 size-medium\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-300x190.gif\" alt=\"mdadm configure screen\" width=\"300\" height=\"190\" srcset=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-300x190.gif 300w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-150x95.gif 150w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-474x300.gif 474w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>If you see this then close your terminal\/Putty session and start again &#8211; using &lt;ctrl&gt;C doesn&#8217;t work. You should instead see:<\/p>\n<figure id=\"attachment_2425\" aria-describedby=\"caption-attachment-2425\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a  href=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02.gif\" class=\"thickbox no_icon\" title=\"mdadm configure screen 2\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2425 size-medium\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-300x164.gif\" alt=\"mdadm configure screen 2\" width=\"300\" height=\"164\" srcset=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-300x164.gif 300w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-150x82.gif 150w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-768x421.gif 768w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-500x274.gif 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2425\" class=\"wp-caption-text\">+ Click to enlarge<\/figcaption><\/figure>\n<p>So at this stage enter &#8220;none&#8221; and press &lt;enter&gt; to continue.<\/p>\n<p>Now run &#8220;lsblk&#8221; to see what filesystems and RAID arrays exist on your system:<\/p>\n<pre class=\"crayon:false;\">root@debian:~# lsblk\nNAME\u00a0\u00a0\u00a0 MAJ:MIN RM\u00a0 SIZE RO TYPE\u00a0 MOUNTPOINT\nsda\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 0 74.5G\u00a0 0 disk\n\u251c\u2500sda1\u00a0\u00a0\u00a0 8:1\u00a0\u00a0\u00a0 0\u00a0 9.6G\u00a0 0 part\n\u251c\u2500sda2\u00a0\u00a0\u00a0 8:2\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 1K\u00a0 0 part\n\u2514\u2500sda5\u00a0\u00a0\u00a0 8:5\u00a0\u00a0\u00a0 0\u00a0 466M\u00a0 0 part\nsdb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:16\u00a0\u00a0 0 74.5G\u00a0 0 disk\n\u2514\u2500md127\u00a0\u00a0 9:127\u00a0 0 74.5G\u00a0 0 raid1\nsdc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:32\u00a0\u00a0 0 74.5G\u00a0 0 disk\n\u2514\u2500md127\u00a0\u00a0 9:127\u00a0 0 74.5G\u00a0 0 raid1\nsdd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:48\u00a0\u00a0 1\u00a0 7.5G\u00a0 0 disk\n\u2514\u2500sdd1\u00a0\u00a0\u00a0 8:49\u00a0\u00a0 1\u00a0 1.2G\u00a0 0 part\u00a0 \/lib\/live\/mount\/medium\nloop0\u00a0\u00a0\u00a0\u00a0 7:0\u00a0\u00a0\u00a0 0\u00a0 1.1G\u00a0 1 loop\u00a0 \/lib\/live\/mount\/rootfs\/filesystem.squashfs<\/pre>\n<p>From the above you can see the array is &#8220;md127&#8221; so create a mount point and mount the array:<\/p>\n<pre class=\"crayon:false;\">mkdir \/raid\nmount \/dev\/md127 \/raid<\/pre>\n<h2>Doing a backup<\/h2>\n<p>For this example we will backup to a local RAID array.<\/p>\n<p>Lets look at lsblk again:<\/p>\n<pre class=\"crayon:false;\">root@debian:\/# lsblk\nNAME\u00a0\u00a0\u00a0 MAJ:MIN RM\u00a0 SIZE RO TYPE\u00a0 MOUNTPOINT\nsda\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 0 74.5G\u00a0 0 disk\n\u251c\u2500sda1\u00a0\u00a0\u00a0 8:1\u00a0\u00a0\u00a0 0\u00a0 6.7G\u00a0 0 part\n\u251c\u2500sda2\u00a0\u00a0\u00a0 8:2\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 1K\u00a0 0 part\n\u2514\u2500sda5\u00a0\u00a0\u00a0 8:5\u00a0\u00a0\u00a0 0\u00a0 341M\u00a0 0 part\nsdb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:16\u00a0\u00a0 0 74.5G\u00a0 0 disk\n\u2514\u2500md127\u00a0\u00a0 9:127\u00a0 0 74.5G\u00a0 0 raid1 \/raid\nsdc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:32\u00a0\u00a0 1\u00a0 7.5G\u00a0 0 disk\n\u2514\u2500sdc1\u00a0\u00a0\u00a0 8:33\u00a0\u00a0 1\u00a0 1.2G\u00a0 0 part\u00a0 \/lib\/live\/mount\/medium\nloop0\u00a0\u00a0\u00a0\u00a0 7:0\u00a0\u00a0\u00a0 0\u00a0 1.1G\u00a0 1 loop\u00a0 \/lib\/live\/mount\/rootfs\/filesystem.squashfs<\/pre>\n<p>So from the above we can see that the system drive is sda. You can also look at the disk sizes as this may give you a clue. Lets look at sda and run fdisk:<\/p>\n<pre class=\"crayon:false;\">root@debian:\/# fdisk -l \/dev\/sda\n\nDisk \/dev\/sda: 74.5 GiB, 80026361856 bytes, 156301488 sectors\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisklabel type: dos\nDisk identifier: 0x00080b9b\n\nDevice\u00a0\u00a0\u00a0\u00a0 Boot\u00a0\u00a0\u00a0 Start\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0 Sectors\u00a0 Size Id Type\n\/dev\/sda1\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2048 13977599 13975552\u00a0 6.7G 83 Linux\n\/dev\/sda2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 13979646 14678015\u00a0\u00a0 698370\u00a0 341M\u00a0 5 Extended\n\/dev\/sda5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 13979648 14678015\u00a0\u00a0 698368\u00a0 341M 82 Linux swap \/ Solaris<\/pre>\n<p>So you can see that the partitions which are actively used go from 0 to 14678015 sectors and the sectors are 512 bytes.<\/p>\n<p>So I will suggest you copy an extra 4096 bytes, just to be safe \ud83d\ude42 so in our case this is:<\/p>\n<p style=\"padding-left: 30px;\">14678015 + 4096 = 14682111<\/p>\n<p>So do a backup by running:<\/p>\n<pre class=\"crayon:false;\">dcfldd bs=512 count=14682111 if=\/dev\/sda | gzip -c &gt; \/raid\/backups\/nas2_10-7-2016_512k-blocks.img.gz<\/pre>\n<p>Note you should set the block size, &#8220;bs=&#8221; in dcfldd to match what fdisk reports, in this case 512. At the end you should see:<\/p>\n<pre class=\"crayon:false;\">root@debian:\/raid#\u00a0 dcfldd bs=512 count=14682111 if=\/dev\/sda | gzip -c &gt; \/raid\/backups\/nas2_10-7-2016_512k-blocks.img.gz\n14681856 blocks (7168Mb) written.\n14682111+0 records in\n14682111+0 records out<\/pre>\n<p>For a 7GB disk this should take say 5 &#8211; 10 minutes but not hours!<\/p>\n<h2>Doing a restore<\/h2>\n<p>Lets look at lsblk again:<\/p>\n<pre class=\"crayon:false;\">root@debian:\/raid\/backups# lsblk\nNAME\u00a0\u00a0\u00a0 MAJ:MIN RM\u00a0 SIZE RO TYPE\u00a0 MOUNTPOINT\nsda\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 1\u00a0 7.5G\u00a0 0 disk\n\u2514\u2500sda1\u00a0\u00a0\u00a0 8:1\u00a0\u00a0\u00a0 1\u00a0 1.2G\u00a0 0 part\u00a0 \/lib\/live\/mount\/medium\nsdb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:16\u00a0\u00a0 0 55.9G\u00a0 0 disk\nsdc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:32\u00a0\u00a0 0 74.5G\u00a0 0 disk\n\u2514\u2500md127\u00a0\u00a0 9:127\u00a0 0 74.5G\u00a0 0 raid1 \/raid\nloop0\u00a0\u00a0\u00a0\u00a0 7:0\u00a0\u00a0\u00a0 0\u00a0 1.1G\u00a0 1 loop\u00a0 \/lib\/live\/mount\/rootfs\/filesystem.squashfs<\/pre>\n<p>So from the above we can see that the system drive is sdb because sda with the &#8220;\/lib\/live\/mount&#8221;.\u00a0 is Debian Live and sdc is the RAID disk.<\/p>\n<p>You can also look at the disk sizes as this may give you a clue.<\/p>\n<p>First run &#8220;fdisk -l&#8221; against your disk to work out the block size:<\/p>\n<pre class=\"crayon:false;\">root@debian:\/raid\/backups# fdisk -l \/dev\/sdb\n\nDisk \/dev\/sdb: 55.9 GiB, 60011642880 bytes, 117210240 sectors\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<\/pre>\n<p>So from the above you can see that for &#8220;dev\/sdb&#8221; the block size is 512<\/p>\n<p>Start the restore by running something like:<\/p>\n<pre class=\"crayon:false;\">gunzip -c \/raid\/backups\/nas2_10-7-2016_512k-blocks.img.gz | dcfldd bs=512 of=\/dev\/sdb<\/pre>\n<p>This will return:<\/p>\n<pre class=\"crayon:false;\">root@debian:\/nas1# gunzip -c \/nas1\/omv2.1_vanilla_7gb-hdd_2-7-2016_512k-blocks.img.gz | dcfldd bs=512 of=\/dev\/sda\n14680064 blocks (7168Mb) written.\n14680064+0 records in\n14680064+0 records out<\/pre>\n<p>So you can see the records count matches and all is good.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Backing up OMV can be a challenge as it doesn&#8217;t have any backup functionality. While there are solutions like Clonezilla and rsync the simplest is &#8220;dd&#8221; or &#8220;dcfldd&#8221;. You should read the article Installing Open Media Vault which explains how I suggest you do it so you don&#8217;t have to backup a 250GB hard drive. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2416","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/2416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2416"}],"version-history":[{"count":20,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/2416\/revisions"}],"predecessor-version":[{"id":5262,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/2416\/revisions\/5262"}],"wp:attachment":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2416"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}