So I've created a system to regularly backup your app data in an incremental way -- so the old data gets retained and snapshot of the latest backups is also taken all using less space. You can restore all this data to a new phone or revert an older version of the data to your existing phone (maybe to get it unbricked without loosing all your settings).
Of course I know about Google's cloud backup, but in my experience it's unreliable, requires a lot of bandwidth and works only on select (Google only) apps. This works on all apps. I also know about adb backup and restore feature, but that also does not work on all apps.
This system requires sshelper app and it must run in the background all the time. You must configure key based login as specified in this (Public-key (passwordless) logins) tutorial. After configuring that, you can disable password based login and disable the 'keep device awake' checkbox to improve on the battery and security.
Other things that is requires is root access.
sshelper installs a busybox. You need to use the tar command cron command of that. The scripts I've deployed use exactly that --
Place this script in /system/bin/custom_data_backup.sh --
# backups data only if the latest one is less than 12 hours old #! /system/bin/sh SECONDS=$((12*60*60)) SD_CARD="Your sdcard mount point" mkdir $SD_CARD/custom_backup latest=`ls -tr $SD_CARD/custom_backup/ | tail -1` if test \( -z "$latest" \) -o \( `date +%s` -gt $(($latest + $SECONDS)) \) then cd /data/data && /data/data/com.arachnoid.sshelper/bin/tar -cpf $SD_CARD/custom_backup/`date +%s` * fi
This can be done by the command (as root) --
vim /system/bin/custom_data_backup.sh
And then pressing 'i' to got to edit mode. Then paste, make changes, then press ESC a few times and type ':x' (without the single quotes).
Modify SD_CARD variable to point to the mount point where your sdcard is mounted. Use the mount command to see the various mount points. One of these must be your SDcard. cd to that place and verify by looking at it's contents if it is indeed the place.
It happens that Android has a bug or a problem etc... the system call which these basic utilities use to seep for a certain period of time is inaccurate. This systemcall never returns when sleep is done for a long period of time. This system works around this problem.
Next you need to setup cron.
Run these commands root --
mkdir /data/data/com.arachnoid.sshelper/spool
vim /data/data/com.arachnoid.sshelper/spool/root
Now press i, then copy paste the following text --
*/30 * * * * custom_data_backup.sh
Then press ESC a few times and type ':x' (without the single quotes).
Then run --
vim /etc/init.d/99backup.sh
Now press i, then copy paste the following text --
#!/system/bin/sh mount -o remount,rw / ln -s /system/bin /bin mount -o remount,ro / /data/data/com.arachnoid.sshelper/bin/crond -c /data/data/com.arachnoid.sshelper/spool
Then press ESC a few times and type ':x' (without the single quotes).
Then run --
chmod 755 /etc/init.d/99backup.sh.
Install universal init.d and enable init.d scripts support. If you've a rom which has inbuilt support of init.d, you will not require this.
After this you must see backups created in directory
No comments:
Post a Comment