FORUMS

[TOOLS][ZIPS][SCRIPTS]Android Backup and Restore Tools[Multiple Devices/Platforms]

3,257 posts
Thanks Meter: 4,165
 
By AndDiSa, Senior Member on 8th December 2019, 02:11 PM
Post Reply Email Thread
android-backup-project
The android backup project provides a set of scripts and tools to backup and/or restore applications installed on Android devices.

This is not adb backup which didn't work for my requirements as
  • it doesn't backup applications if those are requesting not to be backed up
  • it does not support restoring to different devices quite well
  • Google warns that it might be discontinued in future versions of Android


Motivation
I never was really happy about the possibilities to backup / restore Android devices. Especially when you are developing with (different) Android devices, you wish you were able to transfer "configurations" from one device to a different one. Or you would like to revert to an older version of an app or ...

The same is valid when you change your "main" device. The Google mechanism to set up a new device from another one or from a backup works quite well, but has almost the same deficits as adb backup: it doesn't restore all of your apps and data.

Also TWRP or other custom recovery implementation do not really help to get out of this situation. It's fine for creating a backup and restoring it later on the same device but there is no support for switching devices. In addition Android often changes architecture so that TWRP support for a specific device is not guaranteed and at the time of writing there is not even TWRP support for Android 10 yet.

There is another very interesting project related to backup and migration on XDA (https://forum.xda-developers.com/and...-tool-t3862763). Unfortunately it relays on TWRP, too, and has still some issues to be solved.

Last but not least there is Titanium Backup which is available for a very long time now. It works quite well but the free version is very limited in functionality and provides only the possibility to store the backup on the device itself which is a kind of contradiction for a backup.

Some time ago I started already a similar project (https://github.com/AndDiSa/ART) to manage backup and restore of Android devices remotely. Unfortunately it never finished and due to architectural changes of Android it would need a complete workover so that I decided to start over from scratch


Precondition
  • adb installed and in execution path
  • Ubuntu Linux (other should work, too)
  • a rooted Android device (either by adbd unsecure or by e.g. Magisk / SuperSU)


Usage
Theses scripts kind of do that TiBackup is doing, but controlling the backup- and restore process remotely.


backup_apps.sh

./backup_apps.sh [--system-apps]

This script creates a backup of all user (and system) applications and their data. The backup files will be stored in a directory newly created named by the device and the current date.

restore_apps.sh

./restore_apps.sh [<directory_name>]

Ths script restores the apps and their data of a previous backup created by backup_apps.sh Either the directory is identified automatically by the device connected and the current date or you can pass a directory name as parameter. In that case all the apps and data found in the given directory will be restored.

If you want to restore only a part of them, please copy them into a different directory and give that directory as a parameter to the script.

Important

Keep in mind that restoring all apps may cause issues as some have unique IDs that end up causing problems if you use the same unique ID on different devices.

You also may want to consider only restoring apps that are missing from google play or apps that sadly decide to prevent backups of their (i.e. your) data.

full-backup.sh

./full-backup.sh [--data-backup][--no-data-backup][--media-backup][--no-media-backup][--image-backup][--no-image-backup]

This script does a full backup of (different parts of) the /data partition. There are several options to control the behaviour.

--data-backup will backup /data without /data/media and /data/mediadrm

--media-backup will backup /data/media and data/mediadrm

--image-backup will backup the whole partition which is mounted as /data as a 1:1 copy

As it cannot be guaranteed that during the backup process there will be no single modification on the /data partition it's quite common to get a checksum validation failure after the backup is finished.

full-restore.sh

./full-restore.sh [--data-backup][--no-data-backup][--media-backup][--no-media-backup][--image-backup][--no-image-backup] <directory_name>

This script is restoring data previously created by full-backup.sh It accepts the same parameters as full-backup.sh and takes in addition the name of the directory from where the backup shall be restored.


Important

Be very careful in unsing this method, especially when you are restoring /data It will overwrite everything on the /data partition and this may cause major issues up to the point that your device becomes no longer usable. In that case you probably need to do a full wipe to get it working again.

restore-single-partition.sh

./restore-single-partition.sh <path-to-image-to-be-restored> <name-of-the-partition-on-device>

This script is restoring a single partition image previously created by backup-partitions.sh back to the device. The image can be either in compressed or plain format. As parameters you need to give the path to the partition image and the name of the partition as is is configured on the device (see: /dev/block/by-name/<name>).

Important

This command is in experimental state and may be very dangerous as it can fully brick your device. Be very careful in using this method, you have been warned(!).

Downloads:
android-backup-project-v1.6.zip (md5: 00f8dc8630b63fe1398ea61a436c2a0f)
android-backup-project-v1.5.zip (md5: 9cb1183d385f854c1f4b7858855cde58)
android-backup-project-v1.4.zip (md5: 9ad78f33a86e117a72058a336b34ab28)
android-backup-project-v1.3.1.zip (md5: 737a7d3483d98616f650d51eea033619)
android-backup-project-v1.3.zip (md5: 3bb11d4da02754a82f8614a53aacd4df)
android-backup-project-v1.2.zip (md5: 27f365663a97b3c7451938d24ffb7779)
android-backup-project-v1.1.zip (md5: c9806edb32b68109c2fc8e087927ac7a)
android-backup-project-v1.zip (md5: b754cf72fe10c89cdb8e4cb8e94f9e0a)


Special thanks
Credit goes to Raphael Moll who initiated a similar project some time ago and Marc Merlin who improved it to work with Android O. I took some ideas and inspiration from these projects and from my first trial I started years ago. The current implementation does not have much in common with neither of those versions.

Especially I would like to thank @topjohnwu for his great Magisk project and @osm0sis for his great collection of scripts and tools.

XDA:DevDB Information
Android Backup Project, Tool/Utility for all devices (see above for details)

Contributors
AndDiSa
Source Code: https://github.com/AndDiSa/android_backup_project/


Version Information
Status: Stable
Current Stable Version: V1.0
Stable Release Date: 2019-12-08

Created 2019-12-08
Last Updated 2020-01-19
The Following 15 Users Say Thank You to AndDiSa For This Useful Post: [ View ] Gift AndDiSa Ad-Free
8th December 2019, 02:11 PM |#2  
AndDiSa's Avatar
OP Senior Member
Flag Heidelberg
Thanks Meter: 4,165
 
More
Reserved
8th December 2019, 02:11 PM |#3  
AndDiSa's Avatar
OP Senior Member
Flag Heidelberg
Thanks Meter: 4,165
 
More
Reserved
18th December 2019, 10:14 AM |#4  
Junior Member
Thanks Meter: 4
 
More
I there and thanks for the work.
I tried to use your script and I am stuck at "Checking root access"
I am using Magisk. Shell is autorized in #Superuser.
In command line "su" is working see #
Here is my terminal screen
Quote:

[email protected]~
$ bash full-backup.sh --data-backup --media-backup --image-backup
~/busybox-ndk ~
Déjà à jour.
~
Waiting for device...
Devices detected:
List of devices attached
da279704 device

Checking for root access...

[email protected]~
$ adb shell
gemini:/ $ su
gemini:/ #

18th December 2019, 06:38 PM |#5  
AndDiSa's Avatar
OP Senior Member
Flag Heidelberg
Thanks Meter: 4,165
 
More
@cocolol What Android version / device are you using? I did my tests with e.g. a Magisk rooted Pixel 3a on Android 10 without any issues.

Can you try from your command line the following:

adb shell su root -c whoami

and if this is blocked the following:

adb shell su root whoami

probably for your device / configuration

adb shell su whoami

is working
The Following User Says Thank You to AndDiSa For This Useful Post: [ View ] Gift AndDiSa Ad-Free
19th December 2019, 11:09 AM |#6  
AndDiSa's Avatar
OP Senior Member
Flag Heidelberg
Thanks Meter: 4,165
 
More
updated to version 1.1 as there was a quote mismatch in one of the scripts
The Following 2 Users Say Thank You to AndDiSa For This Useful Post: [ View ] Gift AndDiSa Ad-Free
19th December 2019, 10:23 PM |#7  
str8str's Avatar
Senior Member
Flag Kitchener Ontario
Thanks Meter: 1,042
 
Donate to Me
More
Can you backup and restore just user apps?
19th December 2019, 10:48 PM |#8  
AndDiSa's Avatar
OP Senior Member
Flag Heidelberg
Thanks Meter: 4,165
 
More
Quote:
Originally Posted by str8str

Can you backup and restore just user apps?

If you use backup_apps.sh without passing the --system-apps option ... but on Android 10 most likely you will still backup (some) system apps. If there is need for that one could add a filter ...
20th December 2019, 09:35 PM |#9  
Junior Member
Thanks Meter: 4
 
More
@andisa thank you for your prompt reply and sorry for my late answer
I updated script to 1.1 and still be blocked.

Thus "adb shell su root -c whoami" is working answer is "root"
But other commands didn't work (see log below)

My aim is to jump from PE 9 to PE 10 on xiaomi MI5 and MI8 (dipper) with all my apps.
I came here from Migrate app forum which is not working for me since it is TWRP dependend.

Quote:

[email protected] ~
$ bash full-backup.sh --data-backup --media-backup --image-backup
~/busybox-ndk ~
Déjà à jour.
~
Waiting for device...
Devices detected:
List of devices attached
da279704 device

Checking for root access...

[email protected] ~
$ adb shell su root -c whoami
root

[email protected] ~
$ adb shell su root whoami

[email protected] ~
$ adb shell su whoami

21st December 2019, 09:49 AM |#10  
AndDiSa's Avatar
OP Senior Member
Flag Heidelberg
Thanks Meter: 4,165
 
More
@cocolol ok, that's just as it should be, i.e. if you are rooted with Magisk

adb shell su root -c

prefix should work. Question is: why it is blocked within the script.

Edit: I expect that the script is blocked while checking a sane /data partition. Can you try to remove that part from the script? It doesn't harm and we can prove that my expectations are correct. It's sufficient the remove / comment out the checkForCleanData line.
21st December 2019, 04:55 PM |#11  
Senior Member
Thanks Meter: 74
 
More
I got an error: "Unrecognised architecture armv7l".
After adding that to line 82 in functions.sh (and switching flaky usb port) it went through.

Edit:
Device gohan (BQ Aquaris X5 plus)
OS LineageOS 14.1-20191115 (unofficial)
Host Manjaro, bash v5.0.11 (ah well, I had to install PV command)
Edit: fixed device name
The Following User Says Thank You to Keule-T For This Useful Post: [ View ] Gift Keule-T Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes