BackupsResearch » History » Revision 23
Revision 22 (Denis 'GNUtoo' Carikli, 06/08/2020 06:56 PM) → Revision 23/25 (Denis 'GNUtoo' Carikli, 11/09/2020 10:57 PM)
h1. BackupsResearch
{{>toc}}
h2. Introduction
The [[BackupTheEFS]] page has instructions to backup the EFS. This page instead tries to document why it is done in that way, and what are the advantages and disadvantages of various other backups methods.
This can also be useful to write more generic backup instructions to do a more complete backup.
h2. Doing the backup of partitions or other block devices
h3. adb shell cat pipe
Old versions of the "EFS backup instructions":https://redmine.replicant.us/projects/replicant/wiki/BackupTheEFS/17 (up to revision 17) used the following command:
<pre>
adb shell "cat /dev/block/platform/*/by-name/EFS" > EFS.img
</pre>
At some point or under some condition, this stopped working and the backup were corrupted.
h3. adb shell cat adb pull
With something like that:
<pre>
adb shell "cat /dev/block/platform/*/by-name/EFS > /EFS.img"
adb pull /EFS.img ./
</pre>
h4. Two steps
Doing it in two stages like that seem to be widely used in other instructions (like the ones found in XDA forums).
The advantage is that the '*' enables to use the same command across many more devices.
And we need two steps because the '*' is not interpreted by a shell when using adb pull:
<pre>
$ adb pull /dev/block/platform/*/by-name/EFS
adb: error: remote object '/dev/block/platform/*/by-name/EFS' does not exist
$ adb pull "/dev/block/platform/*/by-name/EFS"
adb: error: remote object '/dev/block/platform/*/by-name/EFS' does not exist
$ adb pull '/dev/block/platform/*/by-name/EFS'
adb: error: remote object '/dev/block/platform/*/by-name/EFS' does not exist
</pre>
See the part on [[BackupsResearch#adb-pull-the-block-device|adb-pull-the-block-device]] for more details on how to workaround the lack of expansion and have only 1 command to do the job.
This method requires the partition to be small enough. Otherwise it will create several issues:
* If the partition is bigger than the RAM, the resulting file in / will end up exhausting all the ram, and the backup will fail.
* It instead the partition is big but still fits, doing that would not be very efficient as you would copy the partition once on / to then copy it again through adb.
h4. dd
Normally cat should produce a valid backup, however it might be better to use dd for extra safety.
On Replicant 6.0 0004, at least the recoveries for the following devices have 'dd':
* Galaxy SII (GT-I9100)
* Galaxy Nexus (GT-I9250)
* Galaxy SIII (GT-I9300)
h3. adb pull the block device
The following should also work:
<pre>
adb pull /dev/block/mmcblk0p3 ./EFS.img
</pre>
The advantage is that it can also backup huge partitions like the user data partition or Replicant system partition.
You cannot do @adb pull /dev/block/platform/*/by-name/EFS@ as the expansion of @*@ will fail.
There are possible workarounds:
<pre>
part="`adb shell "ls /dev/block/platform/*/by-name/EFS" | head --bytes=-2`"
adb pull "$part" ./EFS.img
</pre>
Be aware of the @head --bytes=-2@ which is needed to get rid of the nasty @0x0d 0x0a@ line ending returned by @adb@.
(Tested on Recovery of Replicant 6.0 0003.)
h2. Symlinks and adb push
@adb push@ doesn't handle symlinks properly. For instance, with a Galaxy SIII (GT-I9300) with a Replicant 6 recovery, if we use:
<pre>
adb pull /dev/block/platform/dw_mmc/by-name/USERDATA ./USERDATA.img
</pre>
we get the following failure:
<pre>
adb: error: failed to copy 'USERDATA.img' to '/dev/block/platform/dw_mmc/by-name/USERDATA': remote No space left on device
USERDATA.img: 0 files pushed. 4.3 MB/s (436154368 bytes in 96.842s)
</pre>
So here no data has been being written on the data partition and it exhausted the ramdisk of the recovery. This is because instead of writing to that partition, it deleted the @/dev/block/platform/dw_mmc/by-name/USERDATA@ symlink and recreated a file at the same path (@/dev/block/platform/dw_mmc/by-name/USERDATA@) with the data from USERDATA.img.
h2. Backup applications.
It might be a good idea to have a list of backup applications and/or to ship one with Replicant.
* This backup app might be a good option for Replicant 9 or 10: https://github.com/stevesoltys/backup
* F-droid might also has applications. As F-droid packages are not all FSDG compliant, we would need to make sure that the backup application we recommend or ship are FSDG compliant.
It might also be a good idea to understand if the backup solution chosen is sustainable in the long term: If the development stop or upstream decide to make the new version proprietary some users might have a hard time adapting to new backup applications or systems.