[Android Software/Hacking General [Developers Only]] AndDiSa:
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://xdaforums.com/android/apps-games/app-migrate-custom-rom-migration-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-v2.1.zip (md5: b0c71d602963696f7c372d3c2222ae75)

android-backup-project-v2.0.zip (md5: 14be02aa3e2a458ba7d7456dc152dad8)

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 [MENTION=4470081]topjohnwu[/MENTION] for his great Magisk project and [MENTION=4544860]osm0sis[/MENTION] 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