Skip to content

Instantly share code, notes, and snippets.

@ypujante
Created September 18, 2020 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ypujante/2e93e3a30146e84fb2ef8c9e6f19d91c to your computer and use it in GitHub Desktop.
Save ypujante/2e93e3a30146e84fb2ef8c9e6f19d91c to your computer and use it in GitHub Desktop.
Display TimeMachine logs (acts like tail -f)
#!/usr/bin/env bash
# Usage: tm-log.sh [last]
# last: displays up to "last" events before streaming. defaults to 1h (see --last option for log)
LAST=${1:-1h}
ARGS=( --info --predicate 'processImagePath contains "backupd" and subsystem beginswith "com.apple.TimeMachine"' )
# Implementation note: tr -u and sed -l are required (nothing shown until buffer full otherwise!)
tmlog() {
/usr/bin/log "$@" "${ARGS[@]}" | tr -u -s ' ' | sed -l -n 's/com.apple.TimeMachine://gp' | cut -d' ' -f 1,2,10-
}
tmlog show --last $LAST
tmlog stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment