Tuesday, August 29, 2017

Backup Android to linux filesystem

Not sure if I like my Android. Phone is great, Android is great - but not great as well.
(too many walls: why should I not be root? why can I not print, natively? why can i not remove certain apps?)

And up to now, backing up my windows phone (yes, yes) was so much easier, even running while running linux on my machine. Copy, paste per file manager is no fun, per cp it works, but one cannot simply use the mounted file location (at least did not work for me). I imagine the reason for making a backup hard is to make it more likely for users to use the integrated backup to Google servers, so they can scan and analyze the data. I do NOT like that, not here, nor for anything else.

Well, not anymore. With this it is just few steps:

1. connect phone
2. select 'transfer files'
3. run script

I made a small folder, and a script basically containing these steps:
  • Get directory where phone is mounted into a variable (might be easier just take the string after gvfs/ but found this on stackexchange
  • rsync files from card and internal memory to a backup folder without the fluff of caches.


directory=$(ls $XDG_RUNTIME_DIR/gvfs/) #thanks Stackoverflow
rsync -auv --exclude *cache* --exclude */Android/data* /run/user/1000/gvfs/${directory}/* ~/Documents/phone-backup

Why first get the directory name, instead of copying the whole phone? Usage rights did not allow to do that. But this works like a charm, and I run it irregularly depending on how much my phone data changes.

No comments:

Post a Comment

Bookmark and Share