{"id":3938,"date":"2022-01-04T14:00:05","date_gmt":"2022-01-04T22:00:05","guid":{"rendered":"https:\/\/www.cloudacm.com\/?p=3938"},"modified":"2022-01-03T05:38:04","modified_gmt":"2022-01-03T13:38:04","slug":"microsd-backups-with-encryption-that-save-space","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=3938","title":{"rendered":"MicroSD Backups with Encryption that Save Space"},"content":{"rendered":"<p>This post will cover steps on how to create and secure MicroSD backups, with the focus being on disaster recovery for RPi systems.\u00a0 This method of backup is hardly the best method available, but it does offer space savings and more security.\u00a0 In this demonstration, a second Linux system will be used as the backup target with the MicroSD media attached as the backup source.<\/p>\n<p>First step is to establish how large the MicroSD media is and if the target has the space to accommodate.\u00a0 This can be confirmed with the following command, with results that may look similar for others doing this.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">sudo fdisk -l\r\n\r\nDevice Boot Start End Sectors Size Id Type\r\n\/dev\/sdb1 2048 131071 129024 63M c W95 FAT32 (LBA)\r\n\/dev\/sdb2 131072 62333951 62202880 29.7G 83 Linux<\/pre>\n<p>Second step is to run the backup with the following command.\u00a0 Do note that the &#8220;sdb&#8221; reflects the media designation for the MicroSD card based on the earlier fdisk command.\u00a0 Those following these steps may have a different designation, which should be used in the next command&#8217;s &#8220;if=dev\/sdb&#8221; argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">sudo dd if=\/dev\/sdb of=\/home\/local\/Backups\/RPi.img status=progress status=progress<\/pre>\n<p>The duration and speed of the backup will depend on how the MicroSD media is attached.\u00a0 It&#8217;s best to use and card slot, USB adapter, or port that support the fastest throughput.<\/p>\n<p>Third step follows the completion of the backup and is used to change the ownership of the resulting image file since the previous command used &#8220;sudo&#8221;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">sudo chown local \/home\/local\/Backups\/RPi.img<\/pre>\n<p>Forth step is to encrypt and compress the backup.\u00a0 The following command will prompt for a passphrase that will be used to decrypt the image at a later time.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">gpg --no-symkey-cache --output \/home\/local\/Backups\/RPi.gpg --symmetric \/home\/local\/Backups\/RPi.img<\/pre>\n<p>Fifth step is to delete the initial backup since it is using more space and is not encrypted.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">rm \/home\/local\/Backups\/RPi.img<\/pre>\n<p>This will result in a backup of the MicroSD media that both saves space and is secure.\u00a0 When a restore is needed at a later time. this command can be used to decrypt the backup.\u00a0 This will prompt for the passphrase used to encrypt the backup originally.\u00a0 Be aware that the resulting decrypted backup will be uncompressed, so the restore path must have enough free space available.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">gpg --no-symkey-cache --passphrase -o \/home\/local\/Backups\/RPi.img -d \/home\/local\/Backups\/RPi.img.gpg<\/pre>\n<p>Finally, the backup can be restored to the MicroSD media with this command.\u00a0 Be mindful that MicroSD writes take more time than reads, so the restore will take longer than the initial backup.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">sudo dd if=\/home\/local\/Backups\/RPi.img of=\/dev\/sdb status=progress<\/pre>\n<p>Now the MicroSD media is ready for use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post will cover steps on how to create and secure MicroSD backups, with the focus being on disaster recovery for RPi systems.\u00a0 This method of backup is hardly the best method available, but it does offer space savings and more security.\u00a0 In this demonstration, a second Linux system will be used as the backup target with the MicroSD media attached as the backup source. First step is to establish how large the MicroSD media is and if the target&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=3938\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3938","post","type-post","status-publish","format-standard","hentry","category-rd"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/3938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3938"}],"version-history":[{"count":16,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/3938\/revisions"}],"predecessor-version":[{"id":3940,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/3938\/revisions\/3940"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}