Sync data from mobile phone with rsync
I'm quite fond about having a google-free phone. I run a lineage OS without g-apps, use my own caldav and carddav server to sync my contacts and calendars, can find every software I need in the F-Droid app and live happy ever since.
However, what has bugged me was synchronization of personal photos and videos. I did several attempts to solve that using webdav (owncloud/nextcloud), but my phone was not happy with the available clients and the battery would not last very long.
I now have a setup that allows me secure synchronization that I'm quite happy with, using
rsync from my phone to server. It's simple and slim and feels just too familiar to be a bad idea.
Termux - Terminal Emulator and Linux Environment
Termux is what I've been looking for on Android for a long time. Native Linux on my phone would be priceless, but the ease of use and installation makes Termux a more than good compromise. It comes with a nifty packet manager and allows me to run small Python and R scripts including web-scraping etc. on the fly.
You can get Termux for free in the Google Playstore, the extensions however will cost around 2\$ (which is okay, you'll support some really good work!). Using the F-Droid app you can install the extensions for free.
I also installed the extension
Termux:Widget that allows to start scripts via single tap from home screen - a very handy addition, I use it to reboot my raspberry pi or wake-on-lan my computer that's in the basement.
Set up rsync
To set up Termux for this task, install
pkg install rsync
Generate a key-pair (I just use the defaults):
Per default this will create the files
id_rsa.pub in your ~/.ssh directory. Make sure to put the contents of
id_rsa.pub into the
~/.ssh/authorized_keys file on your target server.
And set up the Termux storage:
Create a folder for the
Termux:Widget shortcuts and create the script:
mkdir .shortcuts echo "rsync -h -r --info=progress2 ~/storage/dcim/* robin@<myserver>:/<path_to_my_rsync_folder>" > .shortcuts/sync
With the Termux widget this simple setup allows stable and quick sync of my data that leaves me with a few worries less. In fact I set this up on my wife's phone as well, since it's working so nicely.