summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pahler <luke.linked.in+git@gmail.com>2017-03-18 23:33:14 -0600
committerLuke Pahler <luke.linked.in+git@gmail.com>2017-03-18 23:33:14 -0600
commitec8b34a136c71dc6acd86f401cc703772404836c (patch)
treef897310033d5cfa1865ad82c92461c9458c6363e
parent423a3afb6e137d5d3b60408d14c30bcccb9f25bb (diff)
downloadandbackup-ec8b34a136c71dc6acd86f401cc703772404836c.tar.gz
andbackup-ec8b34a136c71dc6acd86f401cc703772404836c.tar.xz
Starting to implement preservation of cache on a per app basis.
-rw-r--r--README55
-rwxr-xr-xandbackup.sh23
2 files changed, 76 insertions, 2 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..4db802d
--- /dev/null
+++ b/README
@@ -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

Generated by cgit