Rsync Your Android Device

As smart phones, tablets go popular, we'll always encounter this problem: remaining storage space becomes less or even not enough after a period of usage. So we should clean up these devices regularly, this post introduces how to use rsync to back up your android devices

Why Clean-up is needed regularly

Generally smart devices use solid state disk to store data, and we know that SSD has a limited life time for writing in the contrast to HDD, so SSD controller spread the write request to the empty block equally, but as remaining space goes less and less, these blocks will take over more write request than blocks of used space, which will affect the SSD lifetime.

rsync

rsync is a tool we always use to synchronize folders, we could terminate the rsync process at any time, and when we restart it, rsync will ignore the synchronized files and continue the back up job without from beginning. So can we use this tool to back up our android devices?

SSHelper

SSHelper (google play) is the app we need, which will launch ssh service on our android device, then we can use rsync to do the back up job.

Steps

Install and launch SSHelper

SSHelper could be installed from google play, you could also try download it here if google play is not an option.

Configuring SSHelper

There's 3 tabs in SSHelper UI: LOG, CONFIGURATION, TERMINAL, we need to tap CONFIGURATION to modify login password.

https://i.loli.net/2018/07/09/5b434f586ada8.png

After configuring password, SSHelper will notice us to re-launch it. Since SSHelper needs to run in background, we should configure our android system not to terminate SSHelper when it runs in background, then we could do the back-up job on PC.

Back up device storage

Connect the device using ssh

We could use the following command to establish ssh connection to the phone:

ssh <device ip> -p 2222 # Device listening port 2222, which could be found under CONFIGURATION

We'll be logged in after we input password. We can found a SDCard folder using ls command, and DCIM, Pictures folders inside SDCard, let's back up the entire SDCard folder next.

rsync SDCard

The back-up job could be done with the following command:

# rsync -e "ssh -p 2222" -r --copy-links <Device IP>:~/SDCard <back-up folder> such as:
rsync -e "ssh -p 2222" -r --copy-links 172.16.252.196:~/SDCard ~/Downloads/rsync/

Then the only thing we could do is wait, which could be a long time depending on the size of used space, and network speed. We can not check the progress and remaining time using rsync, but we can stop rsync at any time, and continue the back-up job using this command again