summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pahler <luke.linked.in+git@gmail.com>2018-07-06 20:14:36 -0600
committerLuke Pahler <luke.linked.in+git@gmail.com>2018-07-06 20:14:36 -0600
commit2b75bedeabf157dedb63f90071f086fae3d6bb41 (patch)
tree48a1dc8ba172bdb49a5480822c8b83a413223255
parent66c35a714b1c2dc17b740643a5813471b7fdaaa9 (diff)
downloadandbackup-fix-flag-regression.tar.gz
andbackup-fix-flag-regression.tar.xz
During a major overhaul the flag system was broken, specificallyfix-flag-regression
restoring was ignored. I consider this a major regression even though the overhaul added a lot of benefit. On a side note "flag_delimiter" wasn't being used in many places this variable has been around for a while. Other minor things were changed, like a directory not being there on a new O.S. install.
-rwxr-xr-xandbackup.sh36
1 files changed, 24 insertions, 12 deletions
diff --git a/andbackup.sh b/andbackup.sh
index 4296973..ed69128 100755
--- a/andbackup.sh
+++ b/andbackup.sh
@@ -19,9 +19,14 @@
#
set -u
-backups=/sdcard/andbackup
+#backups=/sdcard/andbackup
+#Android pre Nougat
#backups=/storage/ext_sd/bk/andbackup/andbackupBK
-flag_delimiter="-"
+#AICP version
+backups=/mnt/media_rw/034A-1326/Download/bk/andbackup/andbackupBK
+#TWRP version
+#backups=/external_sd/Download/bk/andbackup/andbackupBK
+flag_delimiter=":"
export ANDROID_DATA='/data/data'
export ANDROID_CODE='/data/app'
@@ -84,11 +89,13 @@ lfatal() {
backup_app() {
local app="${1:-}"
- local args="${2:-}"
local preserve_cache=0 # Whether to preserve cache in the backup. Can yield
# notably larger backups for some applications
local origifs=${IFS} # Input field seperator at runtime. Useful for
# reverting
+ IFS=${flag_delimiter}
+ shift
+ local args="${@}"
# Make sure app is specified
if [[ -z ${app} ]]; then
@@ -97,7 +104,6 @@ backup_app() {
fi
# Handle passed arguments
- IFS=' '
for arg in ${args}; do
# Don't clean up the cache if preserveCache is specified
if [ "${arg}" = 'preserveCache' ]; then
@@ -196,10 +202,10 @@ restore_app() {
fi
# When restoring something with flags need to restore app alone
- if [[ 0 = $(echo ${app} | grep -q [${flag_delimiter}]; echo $?) ]]; then
+ if [[ 0 = $(echo ${app} | grep -q "${flag_delimiter}"; echo $?) ]]; then
linfo "This app $app had passed in options"
#Need to get app back to std naming (without params)
- app=`echo ${app} | grep -o ^.*- | sed s/-//g | cat -`
+ app=`echo ${app} | grep -o ^.*- | sed s/${flag_delimiter}//g | cat -`
linfo "Restoring to std name \"${app}\" while we restore"
fi
@@ -226,6 +232,12 @@ restore_app() {
local owner=$(dumpsys package ${app} | grep userId | cut -d'=' -f2 | head -n1)
local data="/data/data/${app}"
+ # If you are restoring to a new/fresh O.S. this directory will not be there
+ if [[ ! -d ${data} ]]; then
+ linfo "Making target restore directory ${app}."
+ mkdir ${data}
+ fi
+
# Decompress data backup
linfo "Decompressing user data for ${app}."
gzip -d -c ${backups}/${app}/data.tar.gz | tar -x -C "${data}"
@@ -233,7 +245,7 @@ restore_app() {
# Fix data permissions
chown -R ${owner}:${owner} "${data}"
# Fix selinux labels
- linfo "Restoring SELinux contexs for ${app}"
+ linfo "Restoring SELinux contexts for ${app}"
restorecon -R "${data}" 2>/dev/null
}
@@ -242,7 +254,7 @@ backup_apps() {
local apps=${@}
[ -z "${apps}" ] && lerror "At least one app is required." && return 1
- IFS=' '
+ IFS=${flag_delimiter}
for app in ${apps}; do
backup_app "${app}"
done
@@ -253,7 +265,7 @@ restore_apps() {
local apps=${@}
[ -z "${apps}" ] && log error "At least one app is required.\n" && return 1
- IFS=' '
+ IFS=${flag_delimiter}
for app in ${apps}; do
restore_app "${app}"
done
@@ -264,15 +276,15 @@ list_backup_apps() {
local list=${1:-}
[ -z "${list}" ] && printf "A backup list is required." && return 1
- local app # Application mame
+ local app # Application name
local args # Application arguments
export IFS=$'\n'
for line in $(cat ${list}); do
# Parse out the app name
- app="$(echo ${line} | tr -s ' ' | cut -d ' ' -f 1)"
+ app="$(echo ${line} | tr -s ' ' | cut -d ${flag_delimiter} -f 1)"
# Parse out the arguments (if any)
- args="$(echo ${line} | tr -s ' ' | cut -s -d ' ' -f 2-)"
+ args="$(echo ${line} | tr -s ' ' | cut -s -d ${flag_delimiter} -f 2-)"
# Execute the backup
backup_app "${app}" "${args}"
done

Generated by cgit