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

Search This thread

AndDiSa

Senior Member
Dec 2, 2009
3,685
5,012
Heidelberg
HTC Desire
@Coldblackice I was very frustrated, too. And I never liked to have a "backup" on the same device I want to back up. So I started some years ago a first attempt which worked quite well but was very hardware specific.
Starting with Android 10 / dynamic partitions and no longer having TWRP available I looked for a different approach. The result are those scripts ... at least for my devices it's working quite well but I didn't check all of them for quite a while now.
 

celrau

Senior Member
Mar 24, 2013
476
86
"Unrecognized architecture armv8l" with magisk v 22.0. Reverted to 21.4 and all is well.
 

Roneo.org

New member
Oct 9, 2021
1
0

AndDiSa

Senior Member
Dec 2, 2009
3,685
5,012
Heidelberg
HTC Desire
@restoremysamsung I never tried that and most likely it will not work. The tool started some time ago and I didn't have the chance to adapt it to the new features starting in Android 11/12/...
There is the possibility to do an image of a partition and to restore that image but I doubt it will work with dynamic partitions.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 28
    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/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 @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
    4
    Uploaded version 1.2 of the tool with the following improvements:
    - support for armv7l architecture
    - checking prerequisites needed by the tool, e.g. adb, pv, ...
    4
    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 Pro)
    OS LineageOS 14.1-20191115 (unofficial)
    Host Manjaro, bash v5.0.11 (ah well, I had to install PV command)
    @Keule-T Thank you very much for the info. I'll add that this change into the next version.
    Would be great if others could report issues / success, too, so we can improve the scripts to be able to run on (almost) every device.
    2
    Missing Permissions

    Magisk Canary in combination with newer Android versions are restricting permissions even on rooted devices more and more. Due to that not all actions required to do a backup / restore are allowed any longer. To circumvent this restrictions there is a new Magisk Module available which enhances the permissions so that the backup / restore scripts are working.

    If you are observing permission issues using the backup / restore scripts please install the AndroidBackupRestore Module in Magisk.

    Edit: Latest Magisk Canary (>=20425) is working again without the need for additional changes
    2
    @Oblias thank you very much for your report. I am very sorry for the mess but it's exactly those reports which help really a lot.

    pv is a program which helps logging the communication between the device and the pc and I did not have in mind that it probably is not installed on a Unix system. I'll add a check for the presence of the important programs so that there is a stable basis before starting the scripts.

    The normal behaviour of the script is as follows:
    - shutdown runtime (to prevent modifications during the backup process)
    - backup apps and data
    - restart runtime

    So a "warm" restart of the device is normal after the backup script finishes. I am only wondering why you had to restore a nandroid ...:confused: