Backing up your android based Fairphone FP2 using ssh and rsync without root access
SSHelper configuration
Install SSHelper from google play store or from its homepage here:
- Disable password logins
- Enable Zeroconf broadcast
- Enable log display server
- Enable clipboard display server
- Prevent standby while running
You have to let open the SSHelper screen on the phone. In my case after screen is off, connection dies.
SSH configuration
Check connection to your device:
$ ssh <android-ip> -p2222
u0_a115@FP2:/data/data/com.arachnoid.sshelper/home $ exit
Create a specific ssh key for using with your device:
ssh-keygen -b 4096 -t rsa -C "fp2@xy" -f ~/.ssh/id_fp2
Now copy your new key to your device:
$ ssh-copy-id -i ~/.ssh/id_fp2 <android-ip> -p2222
SSHelper Version 8.4 Copyright 2014, P. Lutus
Default password is "admin" (recommend: change it)
user@<android-ip>'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '<android-ip>'"
and check to make sure that only the key(s) you wanted were added.
Check connection with ssh key:
$ ssh -i ~/.ssh/id_fp2 <android-ip> -p2222
Backing up directories
Backing up DCIM/ Documents/ Downloads/ and Android/ in this example:
mkdir -p backup/fp2
rsync -rlcv --stats --progress \
--exclude=.thumbnails \
--delete \
<android-ip>:/storage/emulated/0/{DCIM,Documents,Downloads,Android} ~/backup/fp2 1>&2 || return 1
Happy syncing!
Access via sshfs
$ mkdir -p mnt/fp2
$ sshfs <android-ip>:/storage/emulated/0 mnt/fp2/
$ ls ~/mnt/fp2