Backup android on plugin

In a previous post I discussed how to backup android with rsync. In this post, I’ll improve on that solution so it happens when you plug the phone in, rather than manually. My solution happens to know I have only one phone; you should adjust accordingly.

The process is

  1. Plug the phone in
  2. Unlock the screen (you’ll see a prompt to do this).
  3. Backup starts automatically
  4. Wait for the backup to finish before unplugging

First, let’s add a udev rule to auto-mount the phone when it’s plugged in and unlocked, and run appropriate scripts.

Next, we’ll add android-connected and android-disconnected

We’ll add something to mount and unmount the system. Keeping in mind that mounting only works when the screen is unlocked we’ll put that in a loop that checks if the mount worked:

The contents of ¬†/usr/local/bin/phone-backup are pretty me-specific so I’ll omit it, but it copies /media/android over to a server. (fun detail: MTP doesn’t show all information even on a rooted¬†phone, so there’s more work to do)

Tagged , , , . Bookmark the permalink.

2 Responses to Backup android on plugin

  1. Pingback: Android backup on arch linux | Optimal Prime

  2. Pingback: Year in Review | Optimal Prime

Leave a Reply

Your email address will not be published. Required fields are marked *