Skip to content

Commit a42d7ab

Browse files
committed
Fix timestamp race condition in backup_func.sh
Generate backup directory timestamp once to prevent different timestamps if date command executes across second boundaries during directory creation.
1 parent 7394e99 commit a42d7ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
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."

0 commit comments

Comments
 (0)