Backing up your apps (and restoring them) on your rooted Android phone
As a sysadmin, I cannot possibly overemphasize the importance of regularly and systematically backing up ones digital data, and the same is true for content on your Android phone. I suffered an sdcard failure, but thanks to the fact that I regularly backed up the apps on my phone using Titanium Backup, and then backed up the contents of the Titanium Backup's backup folder (which was on the sdcard) onto my workstation, I didn't lose anything. I had installed the rsync binary for Android which I was using to back up all my photographs and videos, apart from the Titanium Backup files, and it did save me a lot of frustration! I now only need to get a new card (getting that is going to be another post altogether, I fear!) and I'll be on my way to getting everything back, just the way it was. If you are under the impression that your sdcard is perfectly reliable, let me shake you out of that reverie and help ensure that you are ready for a crash, whether it occurs or not.
1) If you don't have Titanium Backup, please get it. The paid version allows you to directly upload the backup files to dropbox and what not, but even the free version does a great job. You can even set it to perform automated backups of your apps. The free version only saves backup data onto the sdcard, which you must realize is only half the work.
2) Install rsyncdroid if you haven't done so already. You can get it here.
3) This article talks about how you can use 'Script manager' to set up automated backing up. If you prefer the shorter way, see the section 'My Way'!
My Way
1) Install 'sshdroid' app from the market and run it.
2) Write a simple bash script on your PC/workstation and run it whenever you want. My Wifi setup gives my phone a private ip 192.160.0.5, and I run sshdroid on the standard port 22.
3) Script for my setup is as follows
#!/bin/bash<div>rsync -av –chmod=u=rwX,g=rwX,o=r -e ssh root@192.168.0.5:/mnt/sdcard/dcim/100media/ /home/prashc/htc_backup/100media –rsync-path=/data/rsync</div><div>rsync -av –chmod=u=rwX,g=rwX,o=r -e ssh root@192.168.0.5:/mnt/sdcard/TitaniumBackup/ /home/prashc/htc_backup/TitaniumBackup –rsync-path=/data/rsync
4) Remember to change the paths, as applicable (rsync path, source and destination dir paths).</div>5) Each of the rsync invocations would prompt for a password, but that's quite ok, right? The backup takes only a few seconds as it only copies files which are not already present.
6) You may also want to use the –delete option to rsync to remove files locally when they have been cleared on the phone. This is recommended only for the Titanium backup and not for any other data.
Restoring
If something does go wrong, like your sdcard dying on you, you just need to copy the Titanium Backup directory to the new sdcard and use the Titanium Backup app to do the restoration.
Alternately, you can also do manual restoration (app only, not data). Here's how:
Prereqs:
a)You'll need the Android SDK on your desktop/workstation.
b) adbWireless app on your phone (optional)
1) Connect your phone to your PC/workstation using the USB cable, with USB Debugging turned on. You may just start up the adbWireless app as an alternative.
2) Change to the directory containing adb on your PC/workstation and start adb. If you are using adbWireless, start adb with the IP address and port of your phone, as supplied by the adbWireless app.
3) Unzip the compressed Titanium backup of the apk file of the app you wish to restore, using the gunzip command.
4) Execute "adb install -r <path to apk file>"
As long as there is no space related issue on the phone, the installation should succeed.
Never Forget…
1) …to backup data on your phone!
2) …that you should not move Titanium Backup or apps like busybox, sshdroid, andftp, connectbot etc onto the sdcard, as you won't have these apps on hand, if your sdcard does die on you. A parachute is of no use to you if you don't have it on, when you need it!