-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release scripts and verification progress
- Loading branch information
1 parent
4161431
commit f4fc394
Showing
6 changed files
with
107 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
2021-04-20 Matteo Corti <[email protected]> | ||
|
||
* tmstatus.sh: Verifying progress | ||
|
||
2021-02-16 Matteo Corti <[email protected]> | ||
|
||
* tmstatus.sh: Better phase naminge | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* 2021-04-20, Version 1.3.0 | ||
* Show the progress of the verification step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
(c) Matteo Corti, 2018 | ||
(c) Matteo Corti, 2018-2021 | ||
|
||
# tmstatus.sh | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Show the progress of the verification step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
VERSION=$( grep VERSION tmstatus.sh | sed 's/.*=//' ) | ||
|
||
echo "Version ${VERSION}" | ||
echo 'Did you update the RELEASE_NOTES.md? ' | ||
read -r ANSWER | ||
if [ "x${ANSWER}" = "xy" ] ; then | ||
|
||
make && | ||
gh release create "v${VERSION}" --title "tmstatus.sh-${VERSION}" --notes-file RELEASE_NOTES.md "tmstatus.sh-${VERSION}.tar.gz" "tmstatus.sh-${VERSION}.tar.bz2" | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,26 +4,26 @@ | |
# | ||
# A simple script to summarise the Time Machine backup status | ||
# | ||
# Copyright (c) 2021 Matteo Corti <[email protected]> | ||
# Copyright (c) 2018-2021 Matteo Corti <[email protected]> | ||
# | ||
# This module is free software; you can redistribute it and/or modify it | ||
# under the terms of the Apache Licese v2 | ||
# See the LICENSE file for details. | ||
# | ||
|
||
# shellcheck disable=SC2034 | ||
VERSION=1.2.4 | ||
VERSION=1.3.0 | ||
|
||
format_size(){ | ||
while read -r B ; do | ||
[ "${B}" -lt 1024 ] && echo "${B}" B && break | ||
KB=$(((B+512)/1024)) | ||
[ "${KB}" -lt 1024 ] && echo "${KB}" KB && break | ||
MB=$(((KB+512)/1024)) | ||
[ "${MB}" -lt 1024 ] && echo "${MB}" MB && break | ||
GB=$(((MB+512)/1024)) | ||
[ "${GB}" -lt 1024 ] && echo "${GB}" GB && break | ||
echo $(((GB+512)/1024)) TB | ||
[ "${B}" -lt 1024 ] && echo "${B}" B && break | ||
KB=$(((B+512)/1024)) | ||
[ "${KB}" -lt 1024 ] && echo "${KB}" KB && break | ||
MB=$(((KB+512)/1024)) | ||
[ "${MB}" -lt 1024 ] && echo "${MB}" MB && break | ||
GB=$(((MB+512)/1024)) | ||
[ "${GB}" -lt 1024 ] && echo "${GB}" GB && break | ||
echo $(((GB+512)/1024)) TB | ||
done | ||
} | ||
|
||
|
@@ -39,19 +39,19 @@ days_since(){ | |
days=$(( seconds / 60 / 60 / 24 )) | ||
|
||
echo "${days}" | ||
|
||
} | ||
|
||
format_days_ago() { | ||
|
||
days=$1 | ||
|
||
if [ "${days}" -eq 0 ] ; then | ||
echo 'less than one day ago' | ||
echo 'less than one day ago' | ||
elif [ "${days}" -eq 1 ] ; then | ||
echo "${days} day ago" | ||
echo "${days} day ago" | ||
else | ||
echo "${days} days ago" | ||
echo "${days} days ago" | ||
fi | ||
|
||
} | ||
|
@@ -67,16 +67,16 @@ format_timespan(){ | |
seconds=$((input_in_seconds%60)) | ||
|
||
if [ "${days}" -gt 0 ]; then | ||
[ "${days}" = 1 ] && printf "%d day " "${days}" || printf "%d days " "${days}" | ||
[ "${days}" = 1 ] && printf "%d day " "${days}" || printf "%d days " "${days}" | ||
fi | ||
if [ "${hours}" -gt 0 ]; then | ||
[ "${hours}" = 1 ] && printf "%d hour " "${hours}" || printf "%d hours " "${hours}" | ||
[ "${hours}" = 1 ] && printf "%d hour " "${hours}" || printf "%d hours " "${hours}" | ||
fi | ||
if [ "${minutes}" -gt 0 ]; then | ||
[ "${minutes}" = 1 ] && printf "%d minute " "${minutes}" || printf "%d minutes " "${minutes}" | ||
[ "${minutes}" = 1 ] && printf "%d minute " "${minutes}" || printf "%d minutes " "${minutes}" | ||
fi | ||
if [ "${seconds}" -gt 0 ]; then | ||
[ "${seconds}" = 1 ] && printf "%d second" "${seconds}" || printf "%d seconds" "${seconds}" | ||
[ "${seconds}" = 1 ] && printf "%d second" "${seconds}" || printf "%d seconds" "${seconds}" | ||
fi | ||
|
||
} | ||
|
@@ -89,11 +89,11 @@ printf "Backups %s\\n\\n" "$(hostname)" | |
if tmutil listbackups 2>&1 | grep -q 'No machine directory found for host.' ; then | ||
|
||
if tmutil status 2>&1 | grep -q 'HealthCheckFsck' ; then | ||
|
||
printf 'Time Machine: no information available (performing backup verification)\n' | ||
|
||
else | ||
|
||
printf 'Time Machine (offline):\n' | ||
printf 'Oldest:\t\toffline\n' | ||
printf 'Last:\t\toffline\n' | ||
|
@@ -104,7 +104,7 @@ if tmutil listbackups 2>&1 | grep -q 'No machine directory found for host.' ; th | |
elif tmutil listbackups 2>&1 | grep -q 'No backups found for host.' ; then | ||
|
||
printf 'Time Machine: no backups found\n' | ||
|
||
else | ||
|
||
tm_mount_point=$( tmutil destinationinfo | grep '^Mount\ Point' | sed 's/.*:\ //' ) | ||
|
@@ -118,17 +118,17 @@ else | |
|
||
latestbackup="$( tmutil latestbackup )" | ||
if echo "${latestbackup}" | grep -q '[0-9]' ; then | ||
# a date was returned (should implement a better test) | ||
days=$( days_since "$( tmutil latestbackup | sed 's/.*\///' )" ) | ||
backup_date=$( tmutil latestbackup | sed 's/.*\///' | sed 's/-\([^\-]*\)$/\ \1/' | sed 's/\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/\1:\2:\3/') | ||
printf 'Last:\t\t%s (%s)\n' "${backup_date}" "$( format_days_ago "${days}" )" | ||
# a date was returned (should implement a better test) | ||
days=$( days_since "$( tmutil latestbackup | sed 's/.*\///' )" ) | ||
backup_date=$( tmutil latestbackup | sed 's/.*\///' | sed 's/-\([^\-]*\)$/\ \1/' | sed 's/\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/\1:\2:\3/') | ||
printf 'Last:\t\t%s (%s)\n' "${backup_date}" "$( format_days_ago "${days}" )" | ||
else | ||
printf 'Last:\t\t%s\n' "${latestbackup}" | ||
printf 'Last:\t\t%s\n' "${latestbackup}" | ||
fi | ||
|
||
number=$( tmutil listbackups | wc -l | sed 's/\ //g' ) | ||
printf 'Number:\t\t%s\n' "${number}" | ||
|
||
fi | ||
|
||
echo | ||
|
@@ -160,34 +160,34 @@ fi | |
status=$(tmutil status); | ||
|
||
if echo "${status}" | grep -q 'BackupPhase' ; then | ||
|
||
phase=$( echo "${status}" | grep BackupPhase | sed 's/.*\ =\ //' | sed 's/;.*//' ) | ||
|
||
case "${phase}" in | ||
'ThinningPostBackup') | ||
phase='Finished: thinning backups' | ||
;; | ||
'ThinningPreBackup') | ||
phase='Starting: thinning backups' | ||
;; | ||
'DeletingOldBackups') | ||
phase='Deleting old backups' | ||
;; | ||
'MountingBackupVol') | ||
phase='Mounting backup volume' | ||
;; | ||
'FindingChanges') | ||
phase='Finding changes' | ||
;; | ||
'SizingChanges') | ||
phase='Sizing changes' | ||
;; | ||
'ThinningPostBackup') | ||
phase='Finished: thinning backups' | ||
;; | ||
'ThinningPreBackup') | ||
phase='Starting: thinning backups' | ||
;; | ||
'DeletingOldBackups') | ||
phase='Deleting old backups' | ||
;; | ||
'MountingBackupVol') | ||
phase='Mounting backup volume' | ||
;; | ||
'FindingChanges') | ||
phase='Finding changes' | ||
;; | ||
'SizingChanges') | ||
phase='Sizing changes' | ||
;; | ||
'HealthCheckFsck') | ||
phase='Verifying backup' | ||
;; | ||
'PreparingSourceVolumes') | ||
phase='Preparing source volumes' | ||
;; | ||
'PreparingSourceVolumes') | ||
phase='Preparing source volumes' | ||
;; | ||
'MountingBackupVolForHealthCheck') | ||
phase='Preparing verification' | ||
;; | ||
|
@@ -200,34 +200,33 @@ if echo "${status}" | grep -q 'BackupPhase' ; then | |
echo; | ||
|
||
if echo "${status}" | grep -q Remaining ; then | ||
|
||
secs=$(echo "${status}" | grep Remaining | sed 's/.*\ =\ //' | sed 's/;.*//'); | ||
|
||
# sometimes the remaining time is negative (?) | ||
if ! echo "${secs}" | grep -q '^"-' ; then | ||
|
||
now=$(date +'%s') | ||
end=$(( now + secs )) | ||
end_formatted=$( date -j -f '%s' "${end}" +'%Y-%m-%d %H:%M' ) | ||
duration=$( format_timespan "${secs}" ) | ||
|
||
if [ "$(date -j -f '%s' "${end}" +'%Y-%m-%d')" != "$(date +'%Y-%m-%d')" ] ; then | ||
end_formatted=$( date -j -f '%s' "${end}" +'%Y-%m-%d %H:%M' ) | ||
else | ||
end_formatted=$( date -j -f '%s' "${end}" +'%H:%M' ) | ||
fi | ||
|
||
if [ "${secs}" -eq 0 ] ; then | ||
printf 'Time remaining:\tunknown (finishing)\n' | ||
else | ||
printf 'Time remaining:\t%s (finish by %s)\n' "${duration}" "${end_formatted}" | ||
fi | ||
|
||
|
||
fi | ||
|
||
secs=$(echo "${status}" | grep Remaining | sed 's/.*\ =\ //' | sed 's/;.*//'); | ||
|
||
# sometimes the remaining time is negative (?) | ||
if ! echo "${secs}" | grep -q '^"-' ; then | ||
|
||
now=$(date +'%s') | ||
end=$(( now + secs )) | ||
end_formatted=$( date -j -f '%s' "${end}" +'%Y-%m-%d %H:%M' ) | ||
duration=$( format_timespan "${secs}" ) | ||
|
||
if [ "$(date -j -f '%s' "${end}" +'%Y-%m-%d')" != "$(date +'%Y-%m-%d')" ] ; then | ||
end_formatted=$( date -j -f '%s' "${end}" +'%Y-%m-%d %H:%M' ) | ||
else | ||
end_formatted=$( date -j -f '%s' "${end}" +'%H:%M' ) | ||
fi | ||
|
||
if [ "${secs}" -eq 0 ] ; then | ||
printf 'Time remaining:\tunknown (finishing)\n' | ||
else | ||
printf 'Time remaining:\t%s (finish by %s)\n' "${duration}" "${end_formatted}" | ||
fi | ||
|
||
fi | ||
|
||
fi | ||
|
||
else | ||
|
||
printf 'Status:\t\tStopped\n' | ||
|
@@ -236,9 +235,9 @@ fi | |
|
||
if echo "${status}" | grep '_raw_Percent' | grep -q -v '[0-9]e-' ; then | ||
if echo "${status}" | grep -q '_raw_Percent" = 1;' ; then | ||
percent='100%' | ||
percent='100%' | ||
else | ||
percent=$(echo "${status}" | grep '_raw_Percent" = "0' | sed 's/.*[.]//' | sed 's/\([0-9][0-9]\)\([0-9]\).*/\1.\2%/' | sed 's/^0//') | ||
percent=$(echo "${status}" | grep '_raw_Percent" = "0' | sed 's/.*[.]//' | sed 's/\([0-9][0-9]\)\([0-9]\).*/\1.\2%/' | sed 's/^0//') | ||
fi | ||
printf 'Percent:\t%s\n' "${percent}"; | ||
fi | ||
|
@@ -248,7 +247,15 @@ if echo "${status}" | grep -q 'totalBytes' ; then | |
size=$(echo "${status}" | grep 'bytes\ \=' | sed 's/.*bytes\ \=\ //' | sed 's/;.*//' | format_size) | ||
printf 'Size:\t\t%s of %s\n' "${size}" "${total_size}"; | ||
fi | ||
|
||
|
||
# Print verifying status | ||
if echo "${status}" | grep -q -F HealthCheckFsck ; then | ||
if echo "${status}" | grep -q -F 'Percent = "0' ; then | ||
percent=$( echo "${status}" | grep 'Percent = ' | sed 's/.*Percent\ =\ \"0\.//' | sed 's/\".*//' ) | ||
printf 'Percent:\t%s%%\n' "${percent}"; | ||
fi | ||
fi | ||
|
||
echo | ||
|
||
date | ||
|