-

@ Jurjen de Vries
2025-03-08 22:51:54
I recently switched from stock Android on my Pixel 8 Pro to GrapheneOS and transitioned from Authy to Aegis to move away from Big Tech and embrace open-source and privacy-focused alternatives. While Aegis offers local encrypted backups, I noticed it lacked external automatic sync, and I wanted to be sure that I could still access my 2FA tokens even if I lost my phone, without having to remember to back up Aegis externally every time I added a new 2FA entry.
Additionally, because many commands need to be run in Termux, I found it useful to use Scrcpy to control my Android device from my Ubuntu desktop. Scrcpy requires ADB and allows easy copy-paste functionality between Ubuntu and Android. I used ALT + V in Ubuntu scrcpy and then long-pressed the screen on my Pixel and selected 'Paste' to copy text easily. This is an optional but highly useful method for managing terminal commands efficiently.
This guide will walk you through setting up rclone and Termux:Boot to enable seamless Aegis backup automation on GrapheneOS. While I use GrapheneOS, this setup should work on most modern Android versions.
## Prerequisites
Before starting, make sure you have:
- **GrapheneOS installed** on your Google Pixel Android device (Pixel 8 Pro in my case).
- **Aegis Authenticator** installed with automatic backup enabled.
- **Proton Drive account** ready.
- **Obtainium installed** or an alternative such as F-droid to manage Termux updates securely.
- **Termux & Termux:Boot installed via Obtainium**:
- Termux: [https://github.com/termux/termux-app/releases](https://github.com/termux/termux-app/releases)
- Termux:Boot: [https://github.com/termux/termux-boot/releases](https://github.com/termux/termux-boot/releases)
- **Scrcpy installed** (optional, for easier command handling):
- Install on Ubuntu: `sudo apt install scrcpy`
- Ensure **ADB is enabled** on your Android device.
## Step 1: Install Required Packages and Set Up the Backup Folder
Open Termux and install the required tools:
```sh
pkg update && pkg upgrade -y
pkg install rclone inotify-tools termux-api
```
Grant **storage permissions** to Termux:
```sh
termux-setup-storage
```
Create the **ProtonSync** directory where all files to be backed up will be stored, including Aegis backups:
```sh
mkdir -p /storage/emulated/0/ProtonSync/Aegis/
```
Ensure the directory exists:
```sh
ls /storage/emulated/0/ProtonSync/Aegis/
```
If this returns an empty result (instead of an error), you are ready to proceed.
## Step 2: Configure rclone for Proton Drive
Since August 2024, Proton Drive has been available as a dedicated backend in rclone ([official documentation](https://rclone.org/protondrive/)). However, this integration is still evolving, as it relies on a **proton-api-bridge** that is under active development.
Run:
```sh
rclone config
```
Follow the prompts:
1. Choose **"n"** for a new remote.
2. Name it: `protondrive`
3. Select **Proton Drive** from the list.
4. Enter your **Proton username and password**.
5. If 2FA is enabled, enter the current code from your authenticator app.
6. Confirm and save the remote configuration.
Test the setup by listing files:
```sh
rclone lsd protondrive:
```
If you see your Proton Drive folders, the connection works.
## Step 3: Automate Sync with inotify-tools
We will set up a script to **monitor new Aegis backup files** and sync them instantly.
1. Manually trigger a backup in Aegis first, to ensure a file is created. You can do this in Aegis → Settings → Backups → Trigger backup.
2. Create the sync script directly in the Termux:Boot directory:
```sh
mkdir -p ~/.termux/boot/
nano ~/.termux/boot/watch_protonsync.sh
```
3. Add this content:
```sh
#!/data/data/com.termux/files/usr/bin/bash
inotifywait -m -r -e close_write,moved_to,create /storage/emulated/0/ProtonSync/Aegis/ --format '%w%f' | while read file
do
rclone sync /storage/emulated/0/ProtonSync/Aegis/ protondrive:/ProtonSync/Aegis/ -P
done
```
4. Save and exit (`CTRL + X`, `Y`, `ENTER`).
5. Make it executable:
```sh
chmod +x ~/.termux/boot/watch_protonsync.sh
```
Run it manually to test:
```sh
bash ~/.termux/boot/watch_protonsync.sh &
```
Now, whenever Aegis creates a new backup file, it will automatically sync to Proton Drive.
## Step 4: Test Auto-Start with Termux:Boot
1. Reboot your phone.
2. Open Aegis and manually trigger a backup (`Settings → Backups → Trigger backup`).
3. Check Proton Drive under `/ProtonSync/Aegis/` to confirm that the new backup appears.
If the file is there, the automation works! 🎉
I would advice to keep an eye regularly at the Proton Drive to check if the automation is still working.