2019-03-22 00:26:33 +01:00
|
|
|
# BorgBackup on Android
|
|
|
|
Forked from [ravenschade/borgbackup_on_android](https://github.com/ravenschade/borgbackup_on_android)
|
|
|
|
with modifications from [GAhlekzis](https://github.com/GAhlekzis/borgbackup_on_android).
|
2017-07-29 23:00:13 +02:00
|
|
|
|
|
|
|
|
2019-03-22 00:26:33 +01:00
|
|
|
## Introduction
|
|
|
|
This project provides build scripts to compile [BorgBackup](https://github.com/borgbackup/borg) and its dependencies on
|
|
|
|
Android. It uses [Termux](https://termux.com/) as a lightweight environment.
|
2017-07-29 23:00:13 +02:00
|
|
|
|
2019-03-22 00:26:33 +01:00
|
|
|
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.
|
2017-11-26 00:01:17 +01:00
|
|
|
|
2019-03-22 00:26:33 +01:00
|
|
|
If you have root permission on your device, you can use the "sudo" of Termux, [tsu](https://github.com/cswl/tsu), to
|
|
|
|
conveniently gain root permissions in Termux and backup your complete device.
|
2017-11-26 00:01:17 +01:00
|
|
|
|
2017-07-29 23:00:13 +02:00
|
|
|
|
2019-03-22 02:54:01 +01:00
|
|
|
## Building Borg
|
2019-03-22 00:26:33 +01:00
|
|
|
Install [Termux](https://f-droid.org/en/packages/com.termux/) from F-Droid, open it, and execute the following:
|
|
|
|
```bash
|
|
|
|
pkg install git
|
|
|
|
git clone https://git.caspervk.net/caspervk/borgbackup_on_android
|
|
|
|
cd borgbackup_on_android
|
|
|
|
bash build.sh
|
|
|
|
```
|
2019-03-22 02:54:01 +01:00
|
|
|
If virtualenv for Python does not work properly, set selinux to permissive (`tsudo /system/bin/setenforce 0`).
|
2017-07-30 01:43:53 +02:00
|
|
|
|
2017-07-30 17:26:57 +02:00
|
|
|
Warning messages like
|
2019-03-22 00:26:33 +01:00
|
|
|
```
|
2017-07-30 17:26:57 +02:00
|
|
|
WARNING: linker: /data/data/com.termux/files/usr/lib/libacl.so.1.1.0: unused DT entry: type 0xf arg 0x449
|
2019-03-22 00:26:33 +01:00
|
|
|
```
|
2019-03-22 02:54:01 +01:00
|
|
|
are due to the Android linker. More details can be found [here](https://stackoverflow.com/questions/33206409/unused-dt-entry-type-0x1d-arg).
|
2017-07-30 17:26:57 +02:00
|
|
|
|
2019-03-22 00:26:33 +01:00
|
|
|
Tested with:
|
2019-03-22 02:54:01 +01:00
|
|
|
- Termux 0.56, 0.66
|
|
|
|
- Borg 1.0.12, 1.1.3, 1.2.0a5
|
2017-07-30 17:26:57 +02:00
|
|
|
|
2019-03-22 00:26:33 +01:00
|
|
|
|
|
|
|
## Configuration
|
2019-03-22 02:54:01 +01:00
|
|
|
Install [Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm) and
|
|
|
|
[Termux:Task](https://f-droid.org/packages/com.termux.tasker/) for Termux-Tasker integration.
|
|
|
|
|
|
|
|
Copy backup script to a folder where Termux:Task can find it
|
|
|
|
```bash
|
2019-03-22 03:08:02 +01:00
|
|
|
mkdir -p ~/.termux/tasker
|
|
|
|
cp backup.sh ~/.termux/tasker/backup.sh
|
2017-07-30 01:43:53 +02:00
|
|
|
```
|
2019-03-22 02:54:01 +01:00
|
|
|
|
|
|
|
Create a repository passphrase (and remember to back it up!!)
|
2017-07-30 01:43:53 +02:00
|
|
|
```bash
|
2019-03-22 02:54:01 +01:00
|
|
|
head -c 1024 /dev/urandom | base64 > /data/data/com.termux/files/home/borgbackup_on_android/borg-passphrase
|
2017-07-30 01:43:53 +02:00
|
|
|
```
|
2019-03-22 00:15:40 +01:00
|
|
|
|
2019-03-22 02:54:01 +01:00
|
|
|
Change `<server>` and `<port>` in `borg.sh` to correct values.
|
|
|
|
|
2019-03-22 03:27:17 +01:00
|
|
|
Generate keypair for root with empty password
|
|
|
|
```bash
|
|
|
|
tsudo ssh-keygen -t ed25519
|
|
|
|
tsudo cat
|
|
|
|
```
|
2019-03-22 02:54:01 +01:00
|
|
|
|
2019-03-22 03:27:17 +01:00
|
|
|
Add ~/.ssh/id_ed25519.pub to authorized_users on server
|
|
|
|
```bash
|
|
|
|
command="mkdir -p ~/repos/phone; cd ~/repos/phone; borg serve --restrict-to-path ~/repos/phone",restrict ssh-ed25519 AAA..yX root@phone
|
|
|
|
```
|
2019-03-22 00:26:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
## 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.
|