summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2017-09-28 08:29:47 -0600
committerAaron Ball <nullspoon@oper.io>2017-09-28 08:29:47 -0600
commita11f6a17d5897e741d565ca63a8301eaeee77135 (patch)
tree2e32b4214af8fe9ee97635ab3ce75259a541578d
parent915e58ab88157887a16fbe397eeea4bde450559c (diff)
downloadandbackup-a11f6a17d5897e741d565ca63a8301eaeee77135.tar.gz
andbackup-a11f6a17d5897e741d565ca63a8301eaeee77135.tar.xz
Fixed bug that caused backup of the entire filesystem
I couldn't reproduce this, but it seems that either when the application is installed but hasn't been launched, the data variable is empty, causing the script to backup /* (leads to a very big backup for one app). Now we check to see if data does not exist or is empty and fail if either is true. Also fixed a return code for application not installed. Was returning 1 (error). Now we return 2 (enoent).
-rwxr-xr-xandbackup.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/andbackup.sh b/andbackup.sh
index 70e3552..8df40a5 100755
--- a/andbackup.sh
+++ b/andbackup.sh
@@ -101,7 +101,7 @@ backup_app() {
# Make sure app is installed
if [[ $(dumpsys package ${app} | wc -l) -eq 0 ]]; then
lerror "Package ${app} appears to not be installed."
- return 1
+ return 2
fi
linfo "Backing up ${app}"
@@ -125,6 +125,15 @@ backup_app() {
linfo "${app} apk file could not be found. Skipping apk installer backup."
fi
+ # If the data directory is not found or the data variable is empty, skip
+ # backup. This covers a weird edge case where an application is installed but
+ # hasn't been launched (I think?). The data variable would be empty, causing
+ # this script to backup /*.
+ if [ ! -d "${data:-}" ] || [ -z "${data:-}" ]; then
+ lwarn "No data directory for application '${app}' found. Skipping backup."
+ return 2
+ fi
+
# Copy the user data
cp -rp ${data}/* ${backups}/${app}/data/
# Delete cache directory if it exists

Generated by cgit