diff options
author | Luke Pahler <luke.linked.in+git@gmail.com> | 2017-10-01 19:45:15 -0600 |
---|---|---|
committer | Luke Pahler <luke.linked.in+git@gmail.com> | 2017-10-01 19:45:15 -0600 |
commit | 1d2569958f93d6989c4940cab1bf5263c18a5963 (patch) | |
tree | 2e32b4214af8fe9ee97635ab3ce75259a541578d | |
parent | 915e58ab88157887a16fbe397eeea4bde450559c (diff) | |
parent | a11f6a17d5897e741d565ca63a8301eaeee77135 (diff) | |
download | andbackup-1d2569958f93d6989c4940cab1bf5263c18a5963.tar.gz andbackup-1d2569958f93d6989c4940cab1bf5263c18a5963.tar.xz |
Merge remote-tracking branch 'origin/bug-backup-root'
I did not try to reproduce this edge case but Aaron's code is sound.
Added bonus the 'error no entry' code makes this script more accurate.
-rwxr-xr-x | andbackup.sh | 11 |
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 |