summaryrefslogtreecommitdiff
path: root/andbackup.sh
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 /andbackup.sh
parent423a3afb6e137d5d3b60408d14c30bcccb9f25bb (diff)
downloadandbackup-ec8b34a136c71dc6acd86f401cc703772404836c.tar.gz
andbackup-ec8b34a136c71dc6acd86f401cc703772404836c.tar.xz
Starting to implement preservation of cache on a per app basis.
Diffstat (limited to 'andbackup.sh')
-rwxr-xr-xandbackup.sh23
1 files changed, 21 insertions, 2 deletions
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