diff options
author | Luke Pahler <luke.linked.in+git@gmail.com> | 2017-03-18 23:33:14 -0600 |
---|---|---|
committer | Luke Pahler <luke.linked.in+git@gmail.com> | 2017-03-18 23:33:14 -0600 |
commit | ec8b34a136c71dc6acd86f401cc703772404836c (patch) | |
tree | f897310033d5cfa1865ad82c92461c9458c6363e | |
parent | 423a3afb6e137d5d3b60408d14c30bcccb9f25bb (diff) | |
download | andbackup-ec8b34a136c71dc6acd86f401cc703772404836c.tar.gz andbackup-ec8b34a136c71dc6acd86f401cc703772404836c.tar.xz |
Starting to implement preservation of cache on a per app basis.
-rw-r--r-- | README | 55 | ||||
-rwxr-xr-x | andbackup.sh | 23 |
2 files changed, 76 insertions, 2 deletions
@@ -0,0 +1,55 @@ +CYGWIN +WINDOWS SHELL +BASH + + + +CYGWIN doesn't echo things properly. Like when you hit up arrow instead of showing the last command it travels up in the window. But it still will execute the last command upon hitting <enter>. <tab> autocomplete also doesn't render but still executes. + +Here's sample output of how bad it is on cygwin: +--- +root@htc_himaul:/sdcard2/bk/andbackup # ./and . +./and +andbackup.sh andbackup/ +/andbackup.sh < +sush: ./andbackup.sh: can't execute: Permission denied +126|root@htc_himaul:/sdcard2/bk/andbackup # bash and . +bash and +andbackup.sh andbackup/ +ash andbackup.sh < +shell-init: error retrieving current directory: getcwd: cannot access parent directories: Success +andbackup.sh: line 269: @: unbound variable +1|root@htc_himaul:/sdcard2/bk/andbackup # +--- + + +WINDOWS SHELL doesn't have this problem, so autocomplete and last command are clean. But the "unbound variable" happens also, this is fixed by passing the correct parameter count. (bash bug?) +- +"sh" doesn't work: +--- +1|root@htc_himaul:/sdcard2/bk/andbackup # sh andbackup.sh +127|root@htc_himaul:/sdcard2/bk/andbackup # +--- + + +BASH even has a bug: +--- +shell-init: error retrieving current directory: getcwd: cannot access parent directories: Success +--- +but it appears to run fine + + +TODO BUGS +--- +22:30:17 2017-03-18 info Backing up com.nianticlabs.pokemongo +cp: /storage/ext_sd/bk/andbackup/andbackupBK/com.nianticlabs.pokemongo/data//lib: Function not implemented +deleting cache for com.nianticlabs.pokemongo +22:30:49 2017-03-18 info Compressing userdata for com.nianticlabs.pokemongo +chdir: error retrieving current directory: getcwd: cannot access parent directories: Success +This app com.google.android.apps.maps-preserveDignity has passed in options +22:30:51 2017-03-18 info Backing up com.google.android.apps.maps +deleting cache for com.google.android.apps.maps +22:33:19 2017-03-18 info Compressing userdata for com.google.android.apps.maps +root@htc_himaul:/sdcard2/bk/andbackup # +--- +Looks like andbackup can't handle symlinks diff --git a/andbackup.sh b/andbackup.sh index 40ab224..77624ce 100755 --- a/andbackup.sh +++ b/andbackup.sh @@ -19,7 +19,8 @@ # set -u -backups=/sdcard/andbackup +#backups=/sdcard/andbackup +backups=/storage/ext_sd/bk/andbackup/andbackupBK usage() { @@ -86,6 +87,20 @@ backup_app() { return 1 fi + #If app has "-" that means options are passed in + local preserveCache=false + if [[ 0 = $(echo ${app} | grep --quiet [-]; echo $?) ]]; then + linfo "This app $app has passed in options" + if [[ 0 = $(echo ${app} | grep --quiet "preserveCache"; echo $?) ]]; then + preserveCache=true + fi + #Need to get app back to std naming (without params) + app=`echo ${app} | grep --only-matching ^.*- | sed s/-//g | cat -` + fi + + #DEBUGGING don't want to actaully install + #return 1 + # Make sure app is installed if [[ $(dumpsys package ${app} | wc -l) -eq 0 ]]; then lerror "Package ${app} appears to not be installed." @@ -100,6 +115,7 @@ backup_app() { # Get pertinent metadata local code=$(dumpsys package ${app} | grep codePath | cut -d'=' -f2 | head -n1) local data=$(dumpsys package ${app} | grep dataDir | cut -d'=' -f2 | head -n1) + #linfo HERE is your data dir: $data # Create backup destination if not exist [[ ! -d ${backups} ]] && mkdir -p ${backups} @@ -116,8 +132,11 @@ backup_app() { cp -rp ${data}/* ${backups}/${app}/data/ # Delete cache directory if it exists # This will sometimes significant amounts of space - if [[ -d "${backups}/${app}/data/cache" ]]; then + if [[ -d "${backups}/${app}/data/cache" ]] && ! $preserveCache; then + linfo "Deleting cache for ${app}" rm -rf "${backups}/${app}/data/cache" + else + linfo "Preserving cache for ${app}" fi # Compress the backup |