2.8 KiB
BorgBackup on Android
Forked from ravenschade/borgbackup_on_android with modifications from GAhlekzis.
Introduction
This project provides build scripts to compile BorgBackup and its dependencies on Android. It uses Termux as a lightweight environment.
You do not need root permission on your phone to use it. However, without root permissions the access to data of other apps or system data is not possible, but you can still access your photos, videos.
If you have root permission on your device, you can use the "sudo" of Termux, tsu, to conveniently gain root permissions in Termux and backup your complete device.
Installation
Install Termux from F-Droid, open it, and execute the following:
pkg install git
git clone https://git.caspervk.net/caspervk/borgbackup_on_android
cd borgbackup_on_android
bash build.sh
If virtualenv for Python does not work properly set selinux to permissive (tsudo /system/bin/setenforce 0
).
Warning messages like
WARNING: linker: /data/data/com.termux/files/usr/lib/libacl.so.1.1.0: unused DT entry: type 0xf arg 0x449
are due to the Android linker. More details can be found at https://stackoverflow.com/questions/33206409/unused-dt-entry-type-0x1d-arg.
Tested with:
- termux 0.56
- borg 1.0.12, 1.1.3
Configuration
So all in all my Android backup setup looks like:
- borg, termux and tasker
- termux: Task (https://f-droid.org/packages/com.termux.tasker/) for tasker integration
- tsu (using tsudo of the tsu package)
- .termux/tasker/backup.sh:
#!/data/data/com.termux/files/usr/bin/bash
date
tsudo "~/borgbackup_on_android/borg.sh"
date
read
- ~/borgbackup_on_android/borg.sh:
#!/data/data/com.termux/files/usr/bin/bash
t=`date +%d_%m_%Y`
host=angler
dirs="/ /system /vendor /cache /persist /firmware /storage /data"
export BORG_RSH=borg_ssh_wrapper
source /data/data/com.termux/files/home/borgbackup_on_android/borg-env/bin/activate
borg create -C lz4 -p -v --stats --one-file-system backup:/backup/borg/$host::filesystem-$t $dirs
Dont forget to set ssh configs accordingly!
Known Issues
Borg starting at 1.1 requires the system call sync_file_range (see https://github.com/borgbackup/borg/pull/985 and https://github.com/borgbackup/borg/issues/1961). The linux subsystem in Windows 10 and some older Android versions (for example Lineage including 14.1) do not yet have this. Lineage 15.0 has this call and should work. I have added a test to the build script that checks if sync_file_range is available. If it is not, then I apply a patch (borg_sync_file_range.patch) that replaces this sync with conventional file syncs.