Skip to content

Commit 63e33df

Browse files
authored
Merge pull request #140 from ici0/master
fix timestamp bug; fix duplicate os detection
2 parents 6095300 + a42d7ab commit 63e33df

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

functions/backup_func.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ function backup_func() {
128128
cecho "Skipping compression & encryption due to the 'discouraged_disable_archive' option being set to 'yes'."
129129
cecho "The backup data will be stored in a directory instead."
130130
# TODO: clean up the code, i.e. remove the repetition
131-
declare backup_archive="$archive_path/open-android-backup-$(date +%m-%d-%Y-%H-%M-%S)"
132-
mkdir -p "$archive_path/open-android-backup-$(date +%m-%d-%Y-%H-%M-%S)"
133-
mv ./backup-tmp "$archive_path/open-android-backup-$(date +%m-%d-%Y-%H-%M-%S)"
131+
backup_timestamp=$(date +%m-%d-%Y-%H-%M-%S)
132+
declare backup_archive="$archive_path/open-android-backup-$backup_timestamp"
133+
mkdir -p "$archive_path/open-android-backup-$backup_timestamp"
134+
mv ./backup-tmp "$archive_path/open-android-backup-$backup_timestamp"
134135
else
135136
# Compress
136137
cecho "Compressing & encrypting data - this will take a while."

functions/restore_func.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,26 @@ function restore_func() {
7575
# Apps containing their own directories may contain split APKs, which need to be installed using adb install-multiple.
7676
# Those without directories were created by past versions of this script and need to be imported the traditional way.
7777

78+
# Determine OS and set a command to install apks
79+
if [[ "$(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip')" ]]; then
80+
cecho "Windows/WSL detected"
81+
install_cmd="timeout 900 ./windows-dependencies/adb/adb.exe install-multiple"
82+
elif [[ "$(uname)" == "Darwin" ]]; then
83+
cecho "macOS detected"
84+
install_cmd="gtimeout 900 adb install-multiple"
85+
else
86+
cecho "Linux detected"
87+
install_cmd="timeout 900 adb install-multiple"
88+
fi
7889
# Handle split APKs
7990
# Find directories in the Apps directory
8091
apk_dirs=$(find ./backup-tmp/Apps -mindepth 1 -maxdepth 1 -type d)
8192
for apk_dir in $apk_dirs; do
8293
# Install all APKs in the directory
8394
# the APK files are sorted to ensure that base.apk is installed before split APKs
8495
apk_files=$(find "$apk_dir" -type f -name "*.apk" | sort | tr '\n' ' ')
85-
if [[ "$(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip')" ]]; then
86-
cecho "Windows/WSL detected"
87-
# shellcheck disable=SC2086
88-
timeout 900 ./windows-dependencies/adb/adb.exe install-multiple $apk_files
89-
else
90-
cecho "macOS/Linux detected"
91-
if [[ "$(uname)" == "Darwin" ]]; then
92-
timeout_cmd="gtimeout"
93-
else
94-
timeout_cmd="timeout"
95-
fi
96-
# shellcheck disable=SC2086
97-
$timeout_cmd 900 adb install-multiple $apk_files
98-
fi
96+
# shellcheck disable=SC2086
97+
$install_cmd $apk_files
9998
done
10099

101100
# Now all that's left is ensuring backwards compatibility with old backups

0 commit comments

Comments
 (0)