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
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.