(Solved) - List installed apps
Do you know if there is a command line to list all installed apps on the phone please ? I have in mind the idea to create a backup/restore tool for the phone (backup of contacts, call and sms history, background, installed apps and their settings, system settings), ideally this script must be able to backup a phone and restoring it to another phone (same or different model).
For the contacts I have this path :
For the sms and call history this one :
Thanks for your advice !
It is much easier to craft a backup/restore when in recovery. Simply backup/restore 2 folders /data/system-data and /data/user-data und you got a 100% copy of all relevant things, including installed apps.
Doing it file-by-file is not ideal, as you will loose all system settings etc. The drawback of recovery is, you cannot do it while booted into the live system. There might be better solutions in the future.
@Flohack hi, I'm agree with you, the problem is that I do not have thoses folder on my pro 5 while I'm in recovery !
An other strange things is that when I use the ubports installer, it burn a recovery image that my computer is not able to detect with usb :
[34249.254000] usb 2-1.3: new high-speed USB device number 117 using ehci-pci [34249.283824] usb 2-1.3: no configurations [34249.283831] usb 2-1.3: can't read configurations, error -22 [34249.290021] usb 2-1-port3: unable to enumerate USB device
Even Windows is not recognizing it. I have to burn the old recovey-turbo.img from ubuntu and the it works, Am I the only one to have this issue ?
And with the old recovery my /data folder is empty :
~ # ls cache init.rc service_contexts charger proc sideload data property_contexts storage default.prop ram0 sys dev res system etc root tmp file_contexts sbin ueventd.goldfish.rc fstab.goldfish sdcard ueventd.m86.rc fstab.m86 seapp_contexts ueventd.rc init selinux_version ~ # ls /data ~ #
The user-data partition doesn't seems to be mounted :
~ # mount rootfs on / type rootfs (rw) tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755) devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) tmpfs on /tmp type tmpfs (rw,relatime) /dev/block/platform/15570000.ufs/by-name/cache on /cache type ext4 (rw,nodev,noatime,nodiratime,data=ordered) ~ #
Hi, that's me again ...
I used fastboot to flash the recovery_turbo.img (by the way this issue was closed on github but without details : https://github.com/ubports/ubports-installer/issues/599.
I booted on recovery using adb reboot recovery. I mounted sda44 partition on /data :
adb shell mount /dev/block/sda44 /data
Then I tried adb pull /data/system-data ./
But .... it seems not working when they are symlinks and it fail and stop :
~/Documents/Meizu$ adb pull /data/system-data ./ adb: error: failed to copy '/data/system-data/var/log/installer/media-info' to './system-data/var/log/installer/media-info': remote No such file or directory
After a look at this folder we can see :
~ # ls -l /data/system-data/var/log/installer/media-info __bionic_open_tzdata: couldn't find any tzdata when looking for localtime! __bionic_open_tzdata: couldn't find any tzdata when looking for GMT! __bionic_open_tzdata: couldn't find any tzdata when looking for posixrules! lrwxrwxrwx 1 root root 15 Nov 23 13:26 /data/system-data/var/log/installer/media-info -> /etc/media-info ~ #
How can I then do my backup please ?
Short answer: Its not easy. You have to skip symlinks when pulling those folders, as they are invalid at this time. Long answer: Canonical did not prepare any backup function, and so we are lost with a half-baked concept. Any ideas are welcome how this can be solved better.
@Flohack Hi back, thanks for your answer, I finally manage to do my backup and restore with success (thanks goolge).
I share here how I did:
#!/bin/bash echo "Backing up your data" adb reboot recovery sleep 15 adb shell mount /dev/block/sda44 /data adb shell mkfifo /backup.pipe adb exec-out 'tar -cvp data/system-data 2>/backup.pipe' | dd of=system.tar & adb shell cat /backup.pipe & adb shell rm /backup.pipe adb shell mkfifo /backup.pipe adb exec-out 'tar -cvp data/user-data 2>/backup.pipe' | dd of=user.tar & adb shell cat /backup.pipe & adb shell rm /backup.pipe adb reboot
With this script, you will mount the data partition under the recovery mode, create a pipe to transfer the content of the folder (/data/user-data) through stdout to dd on the local computer in a file named user.tar, then it will do the same for the folder system-data.
Now to restore :
#!/bin/bash echo "Restoring your data" adb reboot recovery sleep 15 adb shell mount /dev/block/sda44 /data adb shell mkfifo /resto.pipe adb push user.tar /resto.pipe & adb shell 'cd /; cat /resto.pipe | tar -xv' adb shell rm /resto.pipe adb shell mkfifo /resto.pipe adb push system.tar /resto.pipe & adb shell 'cd /; cat /resto.pipe | tar -xv' adb reboot
This script will boot the phone into recovery mode, mount the sda44 partition into /data folder, push your backup user.tar through the previously created pipe. On the phone the pipe is catched by cat then sent to tar for decompressing.
Your backup needs to be in the same folder as the script restore because I written it like this.
I tested it and it's perfectly working, I was able to clone one of my Pro 5 to the other one Pro5.
sda44 partition is mostly for Pro5, not sure that this mount works on other model.
I hope that this could help other people.
The best way is maybe to add this feature to ubports-installer, in order to be able to just backup/restore our phone (and of course re-installing it) only with one tool.
What are you thinking about that ?
Well if back up is half baked all we need to is warm the oven to say 425F and put your phone in for 30 mins or so. Backup done!
Sorry I couldn't resist the pointless joke...
@Giiba I will try and let you know ...
@AlainW94 Yes the feature will be added to the installer, but if this script works that would be awesome. I did a similar approach with rsync and ssh back then, but this was very slow. How fast is this, you think?
Also, its maybe easier to put stuff on the SD-CARD locally?
@Flohack Regarding the user-data folder, it took at least 30-35 minutes to backup 12Go (including compression) over usb2.0, and nearly the same (a little faster) to restore (arround 20 minutes).
The system-data folder was smaller then it take less than 5 minutes to backup (and 3 more to restore).
I was thinking about doing it on the SD at the beginning but as my data partition was about 54Go, I was scared that my 32Go SD card wasn't sufficient (as I already had a lot of things on my SD like all the pictures taken by the camera, they are very big on te Pro5 because of the sensor quality).
And one other thing was that my sdcard wasn't mounted on recovery, I think that the recovery-turbo.img miss a lot of features.
For the phone where the system-data and user-data are correctly mounted on the /data folder in recovery, this script can work well if you remove the line "adb shell mount /dev/block/sda44 /data"
But if you want to do that locally on the SD card, if it is mounted, you can do that on the recovery nearly the same way, don't forget to use tar as it will take care of the symlinks (not to ignore them, it will save them too).
It will be very perfect if that can be integrated to the installer !