Skip to content

Commit d8b36ae

Browse files
fix elapsed & last time after multi target handover in restore
1 parent f34cf1c commit d8b36ae

5 files changed

Lines changed: 40 additions & 28 deletions

File tree

scripts/bacchus-restore-new-volume.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ while true; do
4343
fi
4444

4545
if [ ! -f "$source" ]; then
46+
stop_timestamp=$(date +%s)
4647
printf "\nArchive volume %s NOT FOUND in %s\n" "$(basename "$source")" "$bcs_source"
4748
printf "Either place this file in the source directory and press enter\n"
4849
printf "Or enter a new source path and press enter\n"
@@ -52,6 +53,12 @@ while true; do
5253
bcs_source="$newpath"
5354
fi
5455
else
56+
if [ -n "$newpath" ]; then
57+
unset newpath
58+
resume_timestamp=$(date +%s)
59+
start_timestamp_running=$(( start_timestamp_running + (resume_timestamp - stop_timestamp) ))
60+
last_timestamp_running=$(( last_timestamp_running + (resume_timestamp - stop_timestamp) ))
61+
fi
5562
break
5663
fi
5764
done
@@ -68,7 +75,7 @@ else
6875
printf '%s\n' "$filename"
6976
fi
7077

71-
last_timestamp="$(date +%s)"
78+
last_timestamp=$(date +%s)
7279
source="$bcs_source"/"$filename"
7380
Process_Volume "$filename" "$BCS_DECRYPTDIR" "$BCS_COMPRESDIR"
7481

@@ -81,10 +88,10 @@ esac
8188

8289
# Update runtime data to persistence file
8390
runtime_data=$(jo bcs_source="$bcs_source" \
84-
start_timestamp="$start_timestamp" \
85-
start_timestamp_running="$start_timestamp_running" \
86-
last_timestamp="$last_timestamp" \
87-
last_timestamp_running="$last_timestamp_running" \
91+
start_timestamp=$start_timestamp \
92+
start_timestamp_running=$start_timestamp_running \
93+
last_timestamp=$last_timestamp \
94+
last_timestamp_running=0 \
8895
source_size_running="$(( source_size_running + source_actual_size ))" \
8996
dest_size_running="$(( dest_size_running + dest_actual_size ))" \
9097
archive_volumes=$(( archive_volumes + 1 )) )

scripts/bacchus-restore.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ fi
7474

7575
# Process first (possibly only) backup volume
7676
echo "$BCS_BASENAME".tar
77-
timestamp="$(date +%s)"
77+
timestamp=$(date +%s)
7878

7979
source="$BCS_SOURCE"/"$BCS_BASENAME".tar
8080
Process_Volume "$BCS_BASENAME".tar "$BCS_DECRYPTDIR" "$BCS_COMPRESDIR"
8181

8282
# Populate external data structure with starting values
8383
export BCS_DATAFILE="$BCS_TMPFILE".runtime
8484
runtime_data=$(jo bcs_source="$BCS_SOURCE" \
85-
start_timestamp="$timestamp" \
85+
start_timestamp=$timestamp \
8686
start_timestamp_running=0 \
87-
last_timestamp="$timestamp" \
87+
last_timestamp=$timestamp \
8888
last_timestamp_running=0 \
8989
source_size_running=$source_actual_size \
9090
dest_size_running=$dest_actual_size \

scripts/include/backup/completion_stats.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function Completion_Stats()
88
#
99
# start_timestamp
1010
# source_size_running
11+
# dest_size_running
1112
# bcs_dest
1213

1314
local completion_timestamp
@@ -19,12 +20,12 @@ function Completion_Stats()
1920
local comp_ratio
2021

2122
completion_timestamp=$(date +%s)
22-
completion_time=$(( completion_timestamp - start_timestamp + start_timestamp_running ))
23+
completion_time=$(( completion_timestamp - start_timestamp - start_timestamp_running ))
2324
avg_archive_time=$(( (completion_time / (TAR_VOLUME - 1) ) ))
2425

2526
source_size_running_text=$(printf "%'.0f" "$source_size_running")
2627

27-
dest_size=$(du -c "$bcs_dest"/"$BCS_BASENAME"* | tail -1 | awk '{ print $1 }')
28+
dest_size=$(( dest_size_running + $(du -c "$bcs_dest"/"$BCS_BASENAME"* | tail -1 | awk '{ print $1 }') ))
2829
dest_size_text=$(printf "%'.0f" "$dest_size")
2930

3031
comp_ratio=$(( 100 - ( (dest_size * 100) / source_size_running) ))
@@ -34,6 +35,10 @@ function Completion_Stats()
3435
printf 'Average time per archive file: %s\n' "$(Duration_Readable $avg_archive_time)"
3536
printf 'Number of archive files: %s\n' "$(( TAR_VOLUME - 1 ))"
3637
printf 'Total space backed up: %sk\n' "$source_size_running_text"
37-
printf 'Total space on destination: %sk\n' "$dest_size_text"
38+
if [ "$dest_size_running" -ne 0 ]; then
39+
printf 'Total space on destinations: %sk\n' "$dest_size_text"
40+
else
41+
printf 'Total space on destination: %sk\n' "$dest_size_text"
42+
fi
3843
printf 'Overall compression ratio: %s%%\n' "$comp_ratio"
3944
}

scripts/include/restore/completion_stats.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ function Completion_Stats()
99
# dest_size_running
1010

1111
local completion_timestamp
12-
local diff_time
12+
local completion_time
1313
local avg_archive_time
1414
local source_size_running_text
1515
local dest_size_running_text
1616
local comp_ratio
1717

18-
completion_timestamp="$(date +%s)"
19-
diff_time=$(( completion_timestamp - start_timestamp ))
20-
avg_archive_time=$(( (diff_time / archive_volumes) ))
18+
completion_timestamp=$(date +%s)
19+
completion_time=$(( completion_timestamp - start_timestamp - start_timestamp_running ))
20+
avg_archive_time=$(( (completion_time / archive_volumes) ))
2121

2222
source_size_running_text=$(printf "%'.0f" "$source_size_running")
2323
dest_size_running_text=$(printf "%'.0f" "$dest_size_running")
2424

2525
comp_ratio=$(( 100 - ( (source_size_running * 100) / dest_size_running) ))
2626

2727
printf '\nRESTORE OPERATION COMPLETE\n'
28-
printf 'Total runtime: %s\n' "$(Duration_Readable $diff_time)"
28+
printf 'Total runtime: %s\n' "$(Duration_Readable $completion_time)"
2929
printf 'Average time per archive file: %s\n' "$(Duration_Readable $avg_archive_time)"
3030
printf 'Number of archive files: %s\n' "$archive_volumes"
31-
printf 'Total space restored: %sk\n' "$source_size_running_text"
32-
printf 'Total space on source: %sk\n' "$dest_size_running_text"
31+
printf 'Total space on source: %sk\n' "$source_size_running_text"
32+
printf 'Total space restored: %sk\n' "$dest_size_running_text"
3333
printf 'Overall compression ratio: %s%%\n' "$comp_ratio"
3434
}

scripts/include/restore/incremental_stats.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function Incremental_Stats()
1313

1414
local archive_max_name
1515
local max_source_size_text
16-
local completion_timestamp
17-
local diff_time
18-
local last_time
16+
local incremental_timestamp
17+
local elapsed_time
18+
local incremental_time
1919
local avg_archive_time
2020
local comp_ratio
2121
local source_size_running_text
@@ -24,10 +24,10 @@ function Incremental_Stats()
2424
archive_max_name=$(( ${#BCS_BASENAME} + 10 ))
2525
max_source_size_text=$(( 20 ))
2626

27-
completion_timestamp="$(date +%s)"
28-
diff_time=$(( completion_timestamp - start_timestamp ))
29-
last_time=$(( completion_timestamp - last_timestamp ))
30-
avg_archive_time=$(( (diff_time / (TAR_VOLUME - 1) ) ))
27+
incremental_timestamp=$(date +%s)
28+
elapsed_time=$(( incremental_timestamp - start_timestamp - start_timestamp_running ))
29+
incremental_time=$(( incremental_timestamp - last_timestamp - last_timestamp_running ))
30+
avg_archive_time=$(( (elapsed_time / (TAR_VOLUME - 1) ) ))
3131

3232
comp_ratio=$(( 100 - ( (source_size_running * 100) / dest_size_running) ))
3333
source_size_running_text=$(printf "%'.0f" "$source_size_running")
@@ -44,11 +44,11 @@ function Incremental_Stats()
4444
%-${max_source_size_text}s \
4545
%(%m-%d-%Y %H:%M:%S)T\n" \
4646
"$filename" \
47-
"elapsed..$(Duration_Readable $diff_time)" \
48-
"last..$(Duration_Readable $last_time)" \
47+
"elapsed..$(Duration_Readable $elapsed_time)" \
48+
"last..$(Duration_Readable $incremental_time)" \
4949
"avg..$(Duration_Readable $avg_archive_time)" \
5050
"compr..${comp_ratio}%" \
5151
"source..${source_size_running_text}k" \
5252
"dest..${dest_size_running_text}k" \
53-
"$completion_timestamp"
53+
"$incremental_timestamp"
5454
}

0 commit comments

Comments
 (0)