jump to navigation

Automatic Nightly Backups for Your Android Device to Your Computer November 1, 2012

Posted by GuySoft in Android, diy, linux, open source, Uncategorized, wifi, wireless.
Tags: , , , , ,
trackback

Android lifevest

Android backup will keep you safe

Hey all,

Friends keep coming up to me and complaining that they had to wipe all their phone because of some attempt to do something.
However, if you give me a brand-new phone and throw mine out of a high-building window, I won’t stop you, because I have a copy of my phone at home, from that same morning, and I don’t even have to think about it.

Want to feel free again? Not scared that this small thing you carry in your pocket with all your life gets ruined? Well, here is how you do it:

Things you will need

  1. A computer running Linux you can ssh to with Rsync installed, or windows running cygwin with rsync and ssh installed.
  2. Your device needs to be rooted – I am afraid thats a requirement for Titanium backup and all programs that back up app data
  3. Titanium backup – You can use the free version for backing up, but for a single-click restore you will need to pay (I bought it and recommended you do even if its the only thing you ever buy on the play store)
  4. rsync backup for Android – This will back up all your photos and data that isn’t part of your apps, if you don’t root but this is all you want to back up, this post might help you too!
  5. Llama – lets you set location profiles

What to do

  1. On titanium backup, open the “schedules” tab and set up a “Backup all user apps + system data” schedule and tick all the days you want your apps to backup on. Pick a time when you are likely be asleep and not using the phone, for this post lets assume its 6am.
    Titanium Backup, create the backup all apps and data sechedule

    Titanium Backup, create the backup all apps and data schedule

    Titanium Backup, Set the schedule

    Titanium Backup, Set the schedule

  2. On rsync backup for android,
    1. Tap the meny key and select “get binaries
    2. Tap the menu key and select “Generate keys“, this will create for you two files, one in /sdcard/dss_key and another in /sdcard/dss_key.pub (don’t hand your friends the dss_key, its a private key).

      Rsync for android's menu

      Rsync for android’s menu

    3. Tap the menu key and select “Add Profile” and call it “Backup All”, local file or directory should point to /sdcard (or you top-level of all your memory cards).
    4. Set usename to the username on the computer you are doing the ssh to.
    5. Server (IP or hostname) should point to the IP of your PC.
    6. Dropbear SSH private key should point to /sdcard/dss_key
    7. Remote file or directory should point to a folder on your PC (make sure you mkdir -p its path, and that you have writing permissions!).
    8. In Additional rsync options write: -a --exclude external_sd/.android_secure --progress
    9. You can check “Close log window after job if done” so you know in the morning it ran, check “delete remote files that are no longer in source directory. Leave “rsync in reverse” and” send notification using remove notifier” unchekced. Save the new profile.
    Rsync 4 android profile page 1

    Rsync 4 android profile page 1

    Rsync 4 android profile page 2

    Rsync 4 android profile page 2

  3.  On your computer,
    1. You should have ssh and rsync installed, on ubuntu/debian do apt-get install apt-get install rsync openssh-server
    2.  Paste the line from the file /sdcard/dss_key.pub on your phone to ~/.ssh/authorized_keys file on your PC ( Note: it begins with “ssh-dss” and ends with “android@bender”, this is a single line).
    3. At this point I suggest you go to rsync 4 android and tap on the “Backup all” profile you made, make sure that indeed files are getting backed up to your folder, as seen in the picture below. The first sync takes a while, afterwards only changes would be synced. If it does not work, go over the steps above, or comment here and we can try and troubleshoot.

    Rsync for android running

    Rsync for android running

  4. On Llama, (on first use accept the boring stuff) in the “Events” tab delete all the profiles, you don’t need them (if you do want to use Llama for other things feel free to keep them).
    1. Add. New event, name it ‘backup my phone” or something like that.
    2. Add in your new event a condition between 7:00 – 7:30 (or an hour later from when you set titanium to back up)
    3. Add a condition “WiFi Network Connected” and point it to your home wifi, that way it would only work if you are at home, if you have a problem with this condition you can try and set your own way of detecting you are at home
    4. Add a condition Battery Level and set it to “Battery raises above…” and 20%, this makes sure your phone won’t run out of battery at night if unplugged.
    5. Add action “Locale plugin”and select “rsync backup for Android” then pick “Backup All” you created before.

      Llama events setup tab

      Llama events setup tab

    Thats it! Your phone should back up all its apps, and all the information on the sd cards nightly.

    I would love to hear your thoughts and comments :-)

    Links for more information

Comments»

1. Mike - February 5, 2013

Works great, thanks. Is it possible to backup to an already-running (remote) rsync daemon (NICE’d accordingly etc.) via SSH rather than opening a new rsync process on the remote host (which seems to be how this method works)?

2. lapo - February 15, 2013

Using manual “–del” instead of “–delete-after” button it’s possible to use incremental file list (less memory and starts faster).

GuySoft - February 15, 2013

However del might be unsafe if your sync didn’t reach the end on that critical day when things go wrong. But it indeed would speed things

3. Jason - March 2, 2013

I keep getting the following error:
/data/data/eu.kowalczuk.rsync4android/files/ssh: Failed to open /data/.ssh/known_hosts

Host ’192.168.1.10′ key accepted unconditionally.
(fingerprint md5 yadda yadda yadda)
Connection error!

Rsync seems to want me to have an established ssh connection prior to attempting an rsync. Do you know a remedy to this?

GuySoft - March 4, 2013

Hmm, no mention of that error on the net.
Are you sure you set correct permissions:
“chmod 700″ for .ssh and “chmod 600″ for authorized_keys ?

Jason - March 7, 2013

I got the connection working after fixing my ssh keys. But I cannot get away from the following message:

/data/data/eu.kowalczuk.rsync4android/files/ssh: Failed to open /data/.ssh/known_hosts

This doesn’t stop the rsync but is only a nuisance.

4. George - March 26, 2013

If I check the “Close log window after job runs” box, how can I take a look at the log file? Is this kept anywhere? Thanks.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: