{"id":4633,"date":"2022-08-17T22:21:11","date_gmt":"2022-08-17T20:21:11","guid":{"rendered":"https:\/\/eskerahn.dk\/?p=4633"},"modified":"2024-03-05T01:50:02","modified_gmt":"2024-03-05T00:50:02","slug":"partition-backup-unlocked-android-phones","status":"publish","type":"post","link":"https:\/\/eskerahn.dk\/?p=4633","title":{"rendered":"Partition backup, unlocked Android phones, through Recovery."},"content":{"rendered":"<p>Have you ever wanted to backup entire <strong>partitions<\/strong> of your Android phone?<br \/>\nWell it actually is quite easy for an <strong>unlocked<\/strong> device &#8211; Does NOT need to be rooted.<br \/>\n<em><span style=\"color: #ff0000;\"><strong>ADD: This requires the presence of a recovery boot option!<\/strong><\/span> E.g. from LineageOS<\/em><\/p>\n<p><a href=\"https:\/\/eskerahn.dk\/?p=4633\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4634\" src=\"https:\/\/eskerahn.dk\/wp-content\/uploads\/2022\/08\/Backup_Restore_Android.png\" alt=\"\" width=\"617\" height=\"447\" srcset=\"https:\/\/eskerahn.dk\/wp-content\/uploads\/2022\/08\/Backup_Restore_Android.png 617w, https:\/\/eskerahn.dk\/wp-content\/uploads\/2022\/08\/Backup_Restore_Android-300x217.png 300w, https:\/\/eskerahn.dk\/wp-content\/uploads\/2022\/08\/Backup_Restore_Android-150x109.png 150w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/a><\/p>\n<p><span style=\"font-size: 8pt;\">(The above image is &#8216;borrowed&#8217; from <a href=\"https:\/\/7labs.io\/uncategorized\/one-click-backup-restore-android.html\" target=\"_blank\" rel=\"noopener\">here<\/a>)<\/span><\/p>\n<p><!--more--><\/p>\n<p>Here a way to backup partitions, with just the usual <a href=\"https:\/\/developer.android.com\/studio\/releases\/platform-tools\" target=\"_blank\" rel=\"noopener\">ADB<\/a> on the PC. HOWEVER this ONLY works for an <strong>unlocked <\/strong>device.<br \/>\n<em><span style=\"color: #ff0000;\"><strong>ADD: The below requires the presence of a recovery boot option!<\/strong><\/span> E.g. from LineageOS<\/em><\/p>\n<p>For devices with the bootloader <strong>locked<\/strong> <span style=\"color: #ff0000;\"><em><strong>(or no recovery boot)<\/strong><\/em> <\/span>and a PC on <strong>Linux<\/strong>, a somewhat complex method is described <a href=\"https:\/\/community.fxtec.com\/topic\/3609-pro1x-with-sailfishos\/page\/2\/?tab=comments#comment-62495\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>If not unlocked you will need to unlock for the below to work, <strong>BUT <\/strong>both unlock and lock <strong>will wipe all the user data<\/strong>. (like a &#8216;factory reset&#8217;)<br \/>\nThe unlocking procedure is quite straight forward though, <strong>IF<\/strong> the manufacturer has allowed it(!):<br \/>\n<strong>adb reboot boootloader<\/strong>, wait for it to reboot, <strong>fastboot flashing unlock<\/strong>, and yes you guessed what would be needed to lock it again&#8230;.<\/p>\n<p>&nbsp;<\/p>\n<h2>The safe way<\/h2>\n<p>For both <strong>backup<\/strong>, and <strong>restore<\/strong> (unlocked only) I would use this method<br \/>\nThe purpose is to avoid conflicts with a running android:<\/p>\n<ol>\n<li>From a cmd shell run this to boot the connected device into bootloader<\/li>\n<li><strong>adb reboot bootloader<\/strong> or hold down Power and VolDown to you get the bootloader menu.<\/li>\n<li>On device: Use VolDown to roll down to <strong>Recovery<\/strong>, and select with Power<\/li>\n<li>(Await it rebooting into recovery)<\/li>\n<li>Select Advanced\u25baEnable ADB<\/li>\n<li>From a pc cmd shell run<\/li>\n<li><strong>adb shell <\/strong><strong>find \/dev\/block\/platform -name &#8220;by-name&#8221; -exec ls -Al -Z &#8211;color {} \\;<\/strong><\/li>\n<li>Look through the list for the partition(s) of interest. e.g.<br \/>\n<span style=\"color: #00ccff;\"><strong>persist<\/strong> <\/span>-&gt;<span style=\"color: #afaf00;\"> \/dev\/block\/sda2<\/span><\/li>\n<li><strong>adb pull<\/strong>\u00a0 \/dev\/block\/sda2\u00a0\u00a0 <em>persist_some_local_file_name.img<\/em><\/li>\n<li>(Repeat above two for any partition(s) relevant)<\/li>\n<li>On device: From the main menu choose reboot.<\/li>\n<\/ol>\n<p>And <strong>restore<\/strong> is just replacing &#8220;<strong>pull<\/strong>&#8221; with &#8220;<strong>push<\/strong>&#8220;, and swapping the two arguments but I have not tried with persist (yet?), there might be some permission issues<br \/>\n<strong>adb push<\/strong>\u00a0\u00a0 <em>persist_some_local_file_name.img<\/em>\u00a0 \/dev\/block\/sda2<\/p>\n<p><span style=\"font-size: 10pt;\">The idea is from &#8220;way #2&#8221; <a href=\"https:\/\/forum.xda-developers.com\/t\/guide-making-dump-files-out-of-android-device-partitions.2450045\/\" target=\"_blank\" rel=\"external nofollow noopener\" data-cke-saved-href=\"https:\/\/forum.xda-developers.com\/t\/guide-making-dump-files-out-of-android-device-partitions.2450045\/\">here<\/a>, somewhat adjusted, combined with <a href=\"https:\/\/stackoverflow.com\/a\/26977897\" target=\"_blank\" rel=\"external nofollow noopener\" data-cke-saved-href=\"https:\/\/stackoverflow.com\/a\/26977897\">this<\/a>.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3>Tested with userdata<\/h3>\n<p>I tried to pull a 108Gb <strong>userdata<\/strong> partition, booted, took a few pictures and deleted some old ones, and fiddled with some sms&amp;mms too, pushed back with above, booted, <strong>and everything was as before!!<\/strong>\u00a0 \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<h2>A simpler way to backup &#8211; that might not work for all partitions<\/h2>\n<p>If you are on lineageOS or AICP, you can do it without booting to recovery, by in developer options enabling &#8220;USB debugging&#8221;, and &#8220;Rooted debugging&#8221;, and then from a cmd shell just start\/end with &#8220;adb root&#8221; \/ &#8220;adb unroot&#8221;.<br \/>\nObviously this should be done with caution not to interact with the running OS, and I would use it for backup only, not restore.<\/p>\n<p>&nbsp;<\/p>\n<h2>Compression<\/h2>\n<p>Unfortunately ADB does not offer to do compression \/ decompression for you, so I will advice to store to a folder with compression, as the images can be quite large, even on a phone far from filled up. ADB <em>got<\/em> a &#8220;-z&#8221; compression tag for push\/pull, but that does not seem to work as hoped.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to backup entire partitions of your Android phone? Well it actually is quite easy for an unlocked device &#8211; Does NOT need to be rooted. ADD: This requires the presence of a recovery boot option! E.g. from LineageOS (The above image is &#8216;borrowed&#8217; from here)<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,6],"tags":[],"class_list":["post-4633","post","type-post","status-publish","format-standard","hentry","category-pc-and-code-samples","category-phonesphablets"],"_links":{"self":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts\/4633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4633"}],"version-history":[{"count":8,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts\/4633\/revisions"}],"predecessor-version":[{"id":5419,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts\/4633\/revisions\/5419"}],"wp:attachment":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}