Simplifying data backup on Android devices
Backup Assistant
Linux Android Backup offers an open source solution to backing up the most important content from your Android devices in just a few steps.
Backing up data from a Linux installation doesn't pose a problem for most users thanks to open source solutions for almost every scenario, from a single machine to a cluster, as well as command line and GUI options. However, backing up Android devices such as smartphones or tablets can be a little trickier. Up until Android 4, backing up such devices was only possible if the bootloader was unlocked, and unlocking was no easy task because most manufacturers tried to prevent it. And if you did unlock the bootloader, you could void your warranty, and, even worse, risk bricking your device. An advance backup would have made sense, but it was only possible after rooting.
Starting with Android 4, adb backup
[1] (which Google has since deprecated for security reasons) worked reliably without rooting, even between devices by different manufacturers, which differed from many other manufacturer tools or third-party apps. Today, the only official tool left for backups is Android Debug Bridge (ADB), which lets you control Android devices using a computer with Linux, macOS, or Windows. However, using ADB requires many manual steps and still comes with the risk of bricking the device.
Linux Android Backup (LAB), a fledgling project developed on GitHub, offers an alternative to ADB [2]. Under the hood, LAB, which consists of a small shell script and a Flutter app, greatly simplifies backing up Android devices. LAB works entirely without vendor lock-in or closed source software that could compromise your data. While the script is based on ADB, it does not use the deprecated adb backup
command. Despite its name, LAB also works on macOS and Windows, in the Windows Subsystem for Linux (WSL) [3]. In fact, the developers are currently looking for a more suitable name.
Keeping It Simple
LAB aims to keep the backup process for Android devices to just a few steps with minimal interaction with the user. To take advantage of this simplification, you will need to prepare your device up front. However, once you launch the script, LAB requires virtually no intervention. LAB currently backs up installed apps (in APK file format [4]), photos, videos, and other downloads on your device. In contrast to the manual procedure via ADB, LAB also backs up saved contacts in vCard format by installing a small open source helper app. You can submit suggestions for further data to be backed up as an issue on GitHub [2].
The backed up data can be accessed as encrypted archives compressed to the max by 7-Zip; these archives remain accessible even if the script stops working. For this, you will need to install the p7zip-full, adb, curl, and bc packages on your computer. Listing 1 shows the commands for doing this on Debian and Fedora.
Listing 1
Installing Dependencies
### Debian $ sudo apt update && sudo apt install p7zip-full adb curl bc ### Fedora $ dnf update && dnf install p7zip p7zip-plugins adb curl bc
Developer Mode
On your Android device, you now need to unlock developer mode. To do this, go to About the phone at the very bottom of the settings, tap the Build number entry seven times (Figure 1), and then enter your PIN when prompted. The You are now a developer message flashes up briefly on the display. To copy data between the Android device and your computer or laptop, you also need to enable USB debugging (Figure 2). You will find this option hidden in the settings below System & Updates | Developer options. When done, your Android device is ready for backup.
On the PC or laptop where you plan to save your device's backup files, first download LAB [5], unpack the archive, and change to the unpacked directory at the command line. Make sure that your Android device is properly connected to the computer. A prompt then pops up on the connected Android device, asking you whether you want to load or copy data. Select Copy. After pressing Enter the connected device should be detected and tagged as device. If this doesn't happen, press Ctrl+C to cancel the script, check the connection, and restart the script (Figure 3).
Once your device is successfully detected, you will then see the two operating modes: Backup and Restore (Backup will be selected by default). By pressing Enter, you will install the helper app for backing up your contacts from the Android device. The script output (Figure 4) suggests the app has been opened on the smartphone, but this was not true in my test. After manually opening the Linux Android Backup app on your device, you will see an Export Data button, which lets you copy your contacts.
Next, you need to specify the directory where you want LAB to copy the backup data. For the current directory, simply press Enter and the data backup from Android to Linux now begins. Depending on the volume of data to be copied, this can take a few minutes. You can follow the progress in detail on the screen. In my first test with a Huawei Mate 20 Pro, transferring over 16,000 files with a total size of around 18GB took about eight minutes.
Finally, you need to set a password for the encrypted archive; afterward, LAB will create the encrypted archive within a few minutes. The entire process including downloading the app and configuration took about 30 minutes in my test. If successful, LAB will tell you Everything is Ok (Figure 5). The resulting archive from the Huawei Mate 20 Pro was 13GB. Make sure you save your password; without it you will not be able to access your data again. Don't forget to revert the settings you configured for USB Debugging and Developer Mode, as they give more rights than you need in everyday use.
I also repeated this procedure with the new Murena One [6] smartphone, which uses /e/OS as its operating system. /e/OS is based on LineageOS [7], an Android custom ROM based on the Android Open Source Project (AOSP) [8]. I wanted to ensure that LAB also works with custom ROMs. Unlocking developer mode on the Murena One was the same as on the Huawei, but USB debugging was named Android-Debugging on the Murena One and resided in System | Advanced | Developer Options. Again, if you do not find the setting as described here, your best bet is to search the Internet for the specifics for your device.
Restore
Restoring data works the same way as backing up data. However, after the device is detected, do not use the default Backup option. Instead select Restore using the down arrow (Figure 6). First, the helper app should open on the Android device; this did not work on the Murena One either. Instead, I had to open the app manually and this time press Auto-restore contacts. After doing so, I only needed to specify the backup archive's location. You could also insert the archive into the script running in the terminal window using drag and drop. After pressing the Enter key, LAB asked for the password and then opened the archive. The data was then restored automatically (Figure 7).
I also tried out this process on a Google Pixel 3a running GrapheneOS, but the device was not recognized, which is probably due to the security features of this distribution. Upon closer inspection, I found that GrapheneOS comes with its own backup app named SeedVault. Even after disabling SeedVault, the Pixel 3a could not be backed up using LAB.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.