diff options
author | Aaron Ball <nullspoon@oper.io> | 2017-10-26 00:05:44 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2017-10-26 00:05:44 -0600 |
commit | a1cc9dc039be9dcf984503bf52c219982490632a (patch) | |
tree | f1de63368d995cb3a4baf5d8d9f08af1ab778e00 | |
parent | 25d920e381659bd43574b49882e4cc64a5178db8 (diff) | |
download | andbackup-a1cc9dc039be9dcf984503bf52c219982490632a.tar.gz andbackup-a1cc9dc039be9dcf984503bf52c219982490632a.tar.xz |
Refactored part of the restore process
Previously, we installed the apk, extracted the data tarball to the
internal storage, copied the data directory contents to the /data
partition, then cleaned up the temp data directory. This increased io
and made the restore time much slower.
Now we decompress the data backup in memory, and stream its contents
straight to the application install destination (/data/data/...). This
is orders of magnitude faster and reduces storage io extending the life
of the phone storage.
-rwxr-xr-x | andbackup.sh | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/andbackup.sh b/andbackup.sh index 86fdefa..e8bbae8 100755 --- a/andbackup.sh +++ b/andbackup.sh @@ -227,24 +227,17 @@ restore_app() { # Get pertinent metadata local owner=$(dumpsys package ${app} | grep userId | cut -d'=' -f2 | head -n1) - local code=$(dumpsys package ${app} | grep codePath | cut -d'=' -f2 | head -n1) - local data=$(dumpsys package ${app} | grep dataDir | cut -d'=' -f2 | head -n1) + local data="/data/data/${app}" - # Decompress backup + # Decompress data backup linfo "Decompressing user data for ${app}." - cd ${backups}/${app}/ - gzip -d -c data.tar.gz | tar -x + gzip -d -c ${backups}/${app}/data.tar.gz | tar -x -C "${data}" - # Copy the user data in - cp -rp ${backups}/${app}/data/* ${data}/ # Fix data permissions - chown -R ${owner}:${owner} ${data} + chown -R ${owner}:${owner} "${data}" # Fix selinux labels linfo "Restoring SELinux contexs for ${app}" - restorecon -R ${data} 2>/dev/null - - # Cleanup the extracted data so restores don't take too much space - rm -rf ${backups}/${app}/data + restorecon -R "${data}" 2>/dev/null } |