summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2017-10-14 18:37:11 -0600
committerAaron Ball <nullspoon@oper.io>2017-10-20 08:32:14 -0600
commit9a95d9999343026480b6bf934ac31954a64f93de (patch)
tree6e467d4e722162f4d77db26a2c95195878e81490
parent1908ff2864e1cc8068dfab51eefc53f96f0cdbe3 (diff)
downloadandbackup-packaging-process-refactor.tar.gz
andbackup-packaging-process-refactor.tar.xz
Rewrote the package setup and compression processpackaging-process-refactor
Previously, the packaging process created a working directory in which modifications could be made before the final tarball creation. This was problematic because most of the time, the backup destination is on a vfat filesystem, which doesn't support symlinks. Any packages that used symlinks in their data directory would through "Function not implemented" errors during the initial copy of this directory. There were also space concerns with this approach. This updates the package process to construct a tar command. The constructon of this command is where package modifications can be made (eg: --exclude). The usage of tar directly on the source files removes the need to copy files around. This uses much less storage as well as performs much faster as it is now almost entirely done in memory.
-rwxr-xr-xandbackup.sh20
1 files changed, 9 insertions, 11 deletions
diff --git a/andbackup.sh b/andbackup.sh
index 7f5c239..72b8aac 100755
--- a/andbackup.sh
+++ b/andbackup.sh
@@ -85,7 +85,10 @@ lfatal() {
backup_app() {
local app="${1}"
- if [ -z "${app}" ]; then
+ local tar # Tar command for packaging the backup
+
+ # Make sure app is specified
+ if [[ -z ${app} ]]; then
lerror "Application name required."
return 1
fi
@@ -115,8 +118,6 @@ backup_app() {
# Create backup destination if not exist
[ ! -d "${backups}" ] && mkdir -p "${backups}"
- # Delete data stage directory if it exists so we can start new
- [ -d "${backups}/${app}/data" ] && rm -rf "${backups}/${app}/data"
# Backup the apk file if it exists
if [ ! -z "${apk}" ]; then
@@ -150,24 +151,21 @@ backup_app() {
linfo "Skipping application force stop while booted to recovery mode."
fi
- # Copy the user data
- cp -rp "${data}" "${backups}/${app}/data"
+ tar="tar -C ${data} -c "
# Delete cache directory if it exists
# This will sometimes free up significant amounts of space
- if [ ! -d "${backups}/${app}/data/cache" ]; then
+ if [[ ! -d "${data}/cache" ]]; then
linfo "Cache doesn't exist for ${app}"
elif ! $preserveCache; then
- linfo "Deleting cache for ${app}"
- rm -rf "${backups}/${app}/data/cache"
+ linfo "Excluding cache for ${app}"
+ tar="${tar} --exclude=cache"
else
linfo "Preserving cache for ${app}"
fi
# Compress the backup
linfo "Compressing userdata for ${app}"
- cd "${backups}/${app}/"
- tar -c data | gzip -c > data.tar.gz
- rm -rf data
+ ${tar} . | gzip -c > "${backups}/${app}/data.tar.gz"
}

Generated by cgit