Android folder backup via Rsync

Posted on May 1, 2022 by rainbyte
Tags: android, backup, rsync

This post describes how to backup a folder from an Android phone to a PC and restore it on a 2nd phone.

Backup procedure

  1. Download simplesshd on the 1st phone (play store link)

  2. Open simplesshd and click start. The log will show some relevant information:

    • host: something like ip 192.168.x.y
    • port: default is 2222
  3. Run rsync backup command on the PC. Replace <host> and <port> with the correct values for 1st phone!

    rsync -auv --delete -e 'ssh -p <port>' <host>:'/sdcard/orig-dir/' '/path/to/backup-dir/'
    • Rsync will copy files from 1st phone orig-dir folder to PC backup-dir folder
    • delete removes from PC folder the files not in the 1st phone
    • Note: final / on each folder are required!

Restore procedure

  1. Download simplesshd on the 2nd phone (play store link)

  2. Open simplesshd and click start. The log will show some relevant information:

    • host: something like ip 192.168.x.y
    • port: default is 2222
  3. Run rsync restore command on the PC. Replace <host> and <port> with the correct values for 2nd phone!

    rsync -uv --omit-dir-times --no-perms --recursive --inplace --delete -e 'ssh -p <port>' '/path/to/backup-dir/' <host>:'/sdcard/dest-dir/'
    • Rsync will copy files from PC backup-dir folder to 2nd phone dest-dir folder
    • inplace avoids double sdcard write (caused by copy and rename)
    • no-perms is useful when perms are not supported, eg.: mtp mounts
    • omit-dir-times ignores timestamps
    • delete removes from 2nd phone folder the files not in the PC folder
    • Note: final / on each folder are required!
Comments are not open for this post yet.