0

tl;dr

  • I want to backup my internal storage and SD card contents when connected via USB cable
  • due to potentially large amounts of data I don't want to use WiFi-based programs
  • failed attempt at using rsync and gvfs

Is there anything I can do?

Full story

I would like to backup data from my Android based phone (5.1.1 that is currently). I do not want to use an WiFi-based unstable and insecure hacky solutions with SSH and server here and client there (you name it - actually Samsung's very unreliable kies software made me think that way).

By now I used a current Linux Mint (18.2), I tried to read data from the phone using rsync and the mapped storage from gvfs which failed miserably (permission issues, unstable connection).

I would like to script which directories I backup and automate that process as far as possible. Can I make Android act as some sort of virtual device on Windows/Linux that allows some sort of file based access? Or a Web-DAV server connected via USB cable? No free cloud solutions (Google, OneDrive, Dropbox), either, please!

Thank you for your help.

  • Did you try Grsync? Install that and try. The UI is awful but it does the job. I use it to back up phone as also backup selected partitions of laptop to external hard drive – beeshyams Feb 3 '18 at 0:01
  • See this. It also has a test button that simulates backup and throws up errors if any before doing the backup – beeshyams Feb 3 '18 at 0:20
  • You can install from here and it works on 18.3 also add I read elsewhere, though the comments here indicate otherwise – beeshyams Feb 3 '18 at 6:14
  • Thank you, I'll give it a shot and see if it solves my issues. – bash.d Feb 3 '18 at 19:47
0

As most of the time: error in layer 8 of OSI model. Here is what I did and what I should have done:

What I did

I mounted my target external drive using sudo (nothing wrong so far) and thus only root has permissions to write, rsync failed to do anything (which makes sense after all) - even when running using sudo. Where exactly the error was, I am not absolutely sure, but let's focus on

What I sould have done

  • Mount the external device using the GUI tools (for I am using an encrypted external drive)
  • Create a directory in the root of the external drive and chown it to your designated user (or group or both)
  • Run rsync

I created a small script to automate the finding of the gvfs path and rsync to external drive:

#!/bin/bash

PHONE_VENDOR=0000 # your phone vendor here!  
USERID=1 # your user ID here - possibly `id -u`

PHONE_BUS=\`echo $(lsusb -d ${PHONE_VENDOR}:) | cut -d' ' -f 2\`  
PHONE_BUS=${PHONE_BUS}%2C
PHONE_BUS=${PHONE_BUS}\`echo $(lsusb -d ${PHONE_VENDOR}:) | cut -d' ' -f 4 | cut -b 1-3` #extract vendor ID from lsusb  

SOURCEBASE=/run/${USERID}/gvfs/mtp\:host\=%5Busb%3A${PHONE_BUS}%5D
TARGETBASE= # your target base path here

rsync -a --progress ${SOURCEBASE} ${TARGETBASE}  # your rsync commands here

I don't know if anything changes (or this script works) when applying an fstab entry and then mounting via shell and not relying on the GUI tools.

This works for me and provides a neat way to backup contents from Android phones without copying whole SD-cards or internal spaces.

UPDATE - First real attempt

During execution rsync started throwing I/O-errors, probably because the process in general was taking very long (got about 50GB to sync). I am now starting over.
It might be a good idea to start a foundation by manually copying all files initially and all further syncing-processes by using rsync.

UPDATE - Second attempt

So it happens this amount might be too much for one attempt. Maybe this is my crappy smartphone, too. In general it works and after the first initial load-up it will be fine, I guess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.