What is the best practice to partial restore your phone after a factory reset?

I did a backup of my data to my local linux machine. I had to do a factory reset and we verified that at least one of the apps caused the problem, but we don’t know which one.

Now I want to restore my phone app by app and of course I don’t want to loose my data.

What is the best way to achieve this?

What sort of backup did you make?

I basically copied the files into a local folder.

Alright, so you’ve backed up your internal storage and SD card (if you’re using an SD card).

So basically do the reverse of what you did before - although I recommend using ADB, the Android Debug Bridge. It’s faster and more stable than MTP in my experience. It’s in most of the default repos, so yum install adb or apt install adb or what have you.

To allow your PC to connect through ADB, you have to go to Settings > About phone and then tap repeatedly on ‘Build number’ (all the way down) until the phone congratulates you on being a developer. Then go back one step, go to ‘System’, then ‘Advanced’, then ‘Developer options’ and enable ‘USB debugging’.

Then hook up the phone via USB and when it asks to trust the PC it’s being connected to, check the box and hit OK. Now you can use ADB to copy over files.

Looking at your backup, the content of the main folder presumably has two directories: internal memory and the SD card, if you’re using one.

The internal memory is mounted at /storage/emulated/0. So you’d copy over your internal memory backup with

adb push -a /home/myuser/FP3backup/<name of internal storage folder>/* /storage/emulated/0

This copies the entire contents of the internal storage backup folder over to the internal storage of the phone. The -a is so it keeps modification date metadata.

If you have an SD card and you also have to restore its data, you can do the following:

Your SD storage will have unique name, so you can run

adb shell ls /storage

and it’ll display something like

emulated
self
71ED-1519

That directory with the double name in letters and numbers, that’s your SD card. So

adb push -a /home/myuser/FP3backup/<sd card folder>/* /storage/71ED-1519

Replacing 71ED-1519 with whatever your SD card is called, of course.

After doing this your data should be restored.

6 Likes

Thank you for your answer, but I guess with your solution I would have all (!) my apps back on my phone in one go?
What I want to do is restore one app after another. I guess if I restore everything I will also restore my bug, which was the reason I began the whole backup process.

2 Likes

The backup you did didn’t include your apps. If you’ve used apps that save data to internal memory (WhatsApp and others) it’ll include that, but the apps themselves are installed elsewhere and you’ll have to install those from scratch unless you used a backup utility such as oandbackup or Titanium Backup.

3 Likes

Ahhhh ok… yes I did an extra Backup for Signal and Threema.

1 Like

Those will be in place and when you reinstall those apps, they’ll find their backups and you’ll be able to restore them (with their passphrases).

I know WhatsApp stores its encrypted databases and unencrypted media on the internal storage by default, and there’s some other apps that do the same - so those will pick that back up when you reinstall. Stuff like settings and accounts will usually have to be reconfigured though.

I can recommend that app I mentioned earlier, oandbackup, for app backups. It backs up apps and their settings and they can be restored in batches or separately, with or without their data, and you can also just restore data to an already installed app. It backs up all my apps and settings (including wifi access points, contacts, SMS and phone logs) once a week and I then pull the backup files to my PC through ADB. Safe and sound!

so I tried out yur description and it worked fine until the point came
“Then hook up the phone via USB and when it asks to trust the PC it’s being connected to, check the box and hit OK. Now you can use ADB to copy over files.”
That didn’t happen. it says that USB Debugging is active, but it is just connected to load the battery nothing else. No mountable devices are shown in my Gui, and I have no folder /storage in my root directory.

I am definitely a developer and I have 10 000 developer options available. USB-Debugging is active. What went wrong?

When you hook up the phone and run

adb devices

does a device show up?

1 Like
$ adb devices
List of devices attached
* daemon not running; starting now at tcp:5037
* daemon started successfully
A209GR4J0202    unauthorized

When you do that, does the dialog pop up on the phone? It probably didn’t before because adb wasn’t running - an oversight on my part.

2 Likes

YESSSssss… The popup came. Thank you.

I will try the rest now

2 Likes

my default mount folder for any storage devices is “media” (Ubuntu). Since I still have no folder “storage” I look there and ll gives me the following output:

$ ll
ls: Zugriff auf 'FP3' nicht möglich: Der Socket ist nicht verbunden
insgesamt 12
drwxr-x---+ 4 root root 4096 Okt  4 14:59 ./
drwxr-xr-x  4 root root 4096 Feb 13  2019 ../
d?????????? ? ?    ?       ?            ? FP3/
drwxr-xr-x  2 root root 4096 Aug 12  2019 SD/

Which means it cannot access FP3 because the socket is not connected.
But ll on SD shows me an empty folder ( and yes I use an SD-card)

$ ll SD
insgesamt 8
drwxr-xr-x  2 root root 4096 Aug 12  2019 ./
drwxr-x---+ 4 root root 4096 Okt  4 14:59 ../

maybe some leftovers from my mtp connect access are messing this up? Should I reboot?

reboot did help, but both folders show up empty.

$ ll
insgesamt 16
drwxr-x---+ 4 root root 4096 Okt  4 14:59 ./
drwxr-xr-x  4 root root 4096 Feb 13  2019 ../
drwxrwxrwx  2 root root 4096 Okt  4 14:59 FP3/
drwxr-xr-x  2 root root 4096 Aug 12  2019 SD/
anja@THOR:/media/anja$ ll FP3
insgesamt 8
drwxrwxrwx  2 root root 4096 Okt  4 14:59 ./
drwxr-x---+ 4 root root 4096 Okt  4 14:59 ../
anja@THOR:/media/anja$ ll SD
insgesamt 8
drwxr-xr-x  2 root root 4096 Aug 12  2019 ./
drwxr-x---+ 4 root root 4096 Okt  4 14:59 ../

I that ok? I guess at least that SD is empty is to be expected…

$ adb push -a /home/myuser/FP3backup/disk/* media/myuser/SD
adb: error: target 'media/myuser/SD' is not a directory

Somehow it still does not work out…

ADB works a little different, the phone isn’t mounted where you can inspect it without ADB. to inspect the contents on the phone you need to use

adb shell

Which gets you into a shell session where you can cd around inside the phone. You can also give individual commands that pop you back out of the shell immediately, so

adb shell ls /storage/emulated/0

returns the contents of that folder on the phone without opening a shell session.

By the way, if this throwing you for a loop it’s still possible to copy the files over MTP through the usual ‘transfer files’ way. But ADB is one of those things where if you learn the ropes, it makes things that much quicker.

4 Likes

Thank you! That did work!

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.