[HOWTO] Backup and Restore Data on Android Devices

:cry emoji: well that explains why my data was disappearing LOL - I thought it was a continuation of my SD card woes and was continuing to debug it from that angle

Should be tar -czvf /path/to/backup/storage/data_media.tgz /data/media/

Can this news (probably for me only) have in impact on user backup easy usability?

1 Like

Itā€™s coming

Though it looks like itā€™s may not be in v0.15. Itā€™ll arrive one day :slight_smile:

4 Likes

Hello.

Quick question: with two ā€˜sistershipā€™ devices (Moto E 2015), same TWRP and /e/OS (last official, both /e/ from OTA update) can I hope clone one to the other, just restoring nĀ°1ā€™s backup in nĀ°2 ? 2 is a few month olderā€¦ but has a good battery.

Of corse, I will save first ā€˜ordinaryā€™ datas (photos, .vcf and so on) on PC, remove SDcards and SIMs and use a dedicated SDcard as ā€˜external storageā€™ for this operation.

Thanks for your advice.

2 Likes

I believe that TWRP backups are tied to a single device, and cannot be restored to a different device. Backups on SD Card can be found in a TWRP directory, with a sub-directory named by the Serial number of the device (e.g BHS9898XX4F). So you could try copying nĀ°1ā€™s backup from the nĀ°1ā€™s serial number directory to the nĀ°2ā€™s serial number directory.

I would be interested to know if that works if you are able to try it.

3 Likes

OK thanks.

Will try and shareā€¦later (work)

Iā€™ll try to :

  • manually install all apps on the source phone, to the target phone.
  • extract all /data apps directories from TWRP backup
  • restore them on target phone

I donā€™t think a whole restore of /data will work, as it may contains device-specific data.
But it still worth a try :wink:

1 Like

Works :sunglasses: Iā€™m with the clone right now. Have to check details but seems to be OKā€¦

  • backuped first the ā€˜cloneā€™ > has got his TWRP folder and ā€˜serial numberedā€™ subfolder,
  • backuped the ā€˜masterā€™,
  • dragged its backup to PC then droped into cloneā€™s TWRP subfolder,
  • no problem with Restore nor Rebootā€¦

Note that cloneā€™s TWRP went on first page (ā€˜Read onlyā€™): due to wipe (cache + dalvik) during backup ?

3 Likes

Yeah, Iā€™ve done that before on my LG G3 D851. Iā€™ve been through a few of those devices. After copying TWRP backups to a new ā€˜serial numberedā€™ subfolder all restores and bootups worked fine for me also.

As long as two devices are of the exact same variant, sharing backups should be no problem.

2 Likes

If anyone is facing error #255 while backup, itā€™s worth a try to examine recovery.log in TWRPā€™s backup folder :wink:
In my case, it failed on an empty /data/per_boot dir, and succeeded after removing this dir :slight_smile:

2 Likes

I have had another look at the ā€˜Android Backup and Restore Toolsā€™ project which uses shell scripts on a Linux PC to backup and restore apps and data. I looked at it a while ago, but then I started using TWRP backup / restore instead. I decided to revisit this project as a possible alternative to TWRP for backup and restore, to see if it can offer a more flexible and fine-grained backup and restore, specifically for using a known set of user apps and data on different devices and phone models.

After a couple of days experimenting, it is looking pretty good. It will - with some exceptions - restore the same set of apps and data across different phone models. I have only tried devices running the same /e/ and Android version: using it across /e/ and /Android version updates is the next experiment.

It still does not seem to restore accounts, even if you restore the Account Manager app and data, so to use it on a fresh install you need to boot the system, complete the first time setup wizard (including adding an /e/ account), then enable adb root debugging, before you can restore the data. Have fun!

After a bit more experimenting:

  • restore seems to be architecture dependent: I started with a Sony Xperia XZ1 Compact lilac. Apps backed up from there mostly restore fine onto a Z5 Compact suzuran (which was the previous Xperia generation). I then tried on Z3 and Z3 Compact, which were an even earlier generation, and many apps began to fail, when installing apps with multiple apk files in the archive (e.g. app_com.DibsemSoftware.HowManyStrokes.tar.gz, contains the following split apks: split_config.en.apk split_config.arm64_v8a.apk base.apk split_config.xhdpi.apk ). Restoring that archive fails with the error Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113. These archives restored OK on Z5 Compact, but not on Z3/Z3C.

  • All phones involved were running e-0.19-q-20211029

  • So backups from one model may be restorable on some other models, but not all

  • ā€˜failedā€™ apps in this scenario include: Facebook Messenger, Telegram, Cluster, HowManyStrokes, Ebay, Evernote, Garmin Connect & Golf

  • these can sometimes be fixed, by replacing the split apks in the archive with a single APK, where one is available (e.g. for F-Droid apps)

  • Some restored apps keep stopping when run. These can be fixed by deleting app storage, meaning the apps can be restored, but the user data is lost

Iā€™ll add more information here as I discover it.

12 Likes

I gave this a first trial to backup user apps from one device to another and yes, itā€™s looking quite good, as you say. :grinning:

I had a little bit of trouble understanding how to get things running at the start, but most of my questions were solved by reading the xda thread.

Had to install pv (sudo apt install pv) on my ubuntu pc for the script to run as intended.

Backing up on Essential PH-1 (mata) to Xperia XA2 (pioneer). Both devices with usb debugging and rooted debugging enabled; and running e-0.19-r-20211030.

The backup script backed up about 17 apps and their data putting them into a folder it created.

I tried the restore function with only one app and itā€™s data in a folder to start with, Aurora store, and it worked well. The app opened and ran a session straight off. I was quite suprised with that!

Iā€™ll experiment more with this tomorrow; thanks for the heads-up.

4 Likes

There seems to be a live edit option for your post!

Experimented with restoring more apps today (mata to pioneer) and have to say this seems to be a great tool.

K9 all set up a working, Nekogram all good; accounts added, Bromite complete with bookmarks and passwords- that was a surprise! Fdroid with the additional repos I had and a couple of other apps.

Normally when I do any sort of backup itā€™s a tedious manual process, but manageable for the small amount of apps I use; but I can see this method easing the process considerably. Transferring phone history is one thing I would like to be able to do this way but I havenā€™t managed so far. I took another backup_apps with system (which created a much larger folder of 1.2GB) just to get the phone history.

From the backup folder I selected the app and data for com.android.dialer and the same for message as well. After another restore message was all present and correct, but no history in the dialler. Iā€™m keeping logs at the moment but I canā€™t understand a lot of the content.

1 Like

I backup call history (along with SMS Messages) using the 'SMS Backup and Restore` app from Aurora Store. I have it set to do daily backups to a local SD card. So if I need it on a fresh install I just install the app (or restore it with this tool :slight_smile: ) then restore the backed up messages and call logs.

I have had a bit of a play with the --system backup, but not had much joy with it. I wanted to get accounts backed up by backing up and restoring the `Account managerā€™, but the accounts donā€™t get backed up so Iā€™ve given up on it.

Also my main use case for this tool is to have a common set of user apps and data which I can use for testing with different phone models, as I am official maintainer for two devices, and I also test for a third official device which I happen to own, and another unofficial device. I had real problems getting backed up system apps from one device restored on a different model, so I gave up because that use case isnā€™t so important to me.

The other important use case is to back up my ā€˜daily driverā€™ and my wifeā€™s (which runs LineageOS with GApps), as a ā€œbelt and bracesā€ strategy in addition to backing up with TWRP. Again, I donā€™t really need system apps and their data for that. Worst case is I have to input my /e/ and OwnDrive NextCloud accounts, because they are held in Account Manager. I have a backup of my email account settings from K-9 Mail, and all my other data (Contacts, Calendar, Notes) lives in various clouds.

So good luck with trying to get what you want out of --system, but for me the small amount of stuff held there isnā€™t worth the extra hassle. Iā€™ve now got a set of user apps and data that I can flash to a freshly installed device in a single operation which take 10-15 minutes, and which - unlike TWRP - can be used to restore just a single app at a time. So I am a happy ROM maintainer and /e/ user :slight_smile:

4 Likes

Thanks Pete, learn something new all the time. Iā€™d not cottoned on to the export settings capability of K9 lol, 2 seconds and youā€™re sorted. What a great app.

SMS Backup and Restore is my ā€˜normalā€™ route although I donā€™t like itā€™s tracker count; but I guess Iā€™ll stick with it.

Yup, Iā€™ll be following your lead on that; probably wonā€™t bother with it. Itā€™s good to try things out though and see what you can get with the tools available. I donā€™t use twrp much as it doesnā€™t work well on android 11 and the devices I have. Thisā€™ll be good for helping set up devices at testing time though and Iā€™ll certainly be using it next time I need to restore my daily driver (mata)

Iā€™ve recently acquired an xz2c. Wanted one for a long time. Itā€™s a great little phone. I think thatā€™s one of yourā€™s, no?

Agreed. Iā€™ve been using it for many years an wouldnā€™t be without it.

No. My daily driver is the XZ1C, for which I make unofficial and custom builds. When I was looking for a replacement for the Z5C Iused previously, I looked at the XZ2C, but rejected it because itā€™s bigger, it has no headphone jack socket, and - at the time - it was significantly more expensive.

1 Like

Alrighty folks, I have some good news.
For backing up SMS/MMS I have been using SMS Backup & Restore (Pro) for years. Has never failed plus there really hasnā€™t been anything that comes close.

For some time, on F-Droid there has been an app called SMS Import/Export that uses JSON file format. Ignored because it didnā€™t backup MMS. With the latest version that has changed. MMS is now supported.

Test drive on my daily driver Nougat setup (not /e/OS).
First, backed up using SMS Backup & Restore (just in case). About 1100 messages.
Then exported messages with SMS I/E. No errors.
Deleted all messages and rebooted for good measure.
Set SMS I/E as the default SMS app. Imported the messages. No errors.
Reset my default SMS app and reboot.

All messages, media, proper order/threading was intact. It went perfect.
When exporting you can choose where to save.
Now folks have a usable FLOSS alternative. Sure, it doesnā€™t have all the extra features but for most, backing up and restoring is all that matters.

SMS Import / Export | F-Droid

7 Likes

Does SMS Import/Export support scheduled backups? That is mainly how I use SMS Backup and Restore, to ensure I always have an up-to-date backup (without having to remember to run a backup before I flash a new ROM version)

No, not yet. I went browsing around the issue tracker and the topic of scheduling has come up. I believe the dev is looking into it.
Read a post from the dev where he didnā€™t think anyone would be using the app. Something about being a proof-of-concept and learning thing. Folks requested MMS support so he obliged. Hopefully he can add scheduling or auto backups. An issue for that was opened just a day ago.

Issue # 7 ([feature] Periodic backup support) at tmo1/sms-ie

2 Likes