Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors when running on macOS 10.13.3 #5

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions restic-runner
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Options
EOF
}
function log {
echo "LOG ($(date --rfc-3339=seconds)): $@" >&2
echo "LOG ($(date "+%Y-%m-%d %H:%M:%S")): $@" >&2
}

function cleanup {
Expand Down Expand Up @@ -145,8 +145,9 @@ function human_duration {
# $2 should be the later timestamp. Timestamps should be strings
# in any form that GNU date accepts.

local ts1=$(date +%s --date "$1")
local ts2=$(date +%s --date "$2")
local ts1=$1
local ts2=$2

local difference=$(( $ts2 - $ts1 ))

local hours=$(bc <<<"$difference / 60 / 60")
Expand Down Expand Up @@ -396,15 +397,15 @@ type $command &>/dev/null || die "No such command: $command"
# du. Restic outputs its own duration, so there's no reason to
# duplicate that, but it might be useful to know how much extra time
# is taken by running du before and after.
date_before=$(date)
date_before=$(date +%s)
du_enabled && du_before=$(repo_du)

# Run command (backup, forget, prune, etc.)
$command || die "$command failed."

# Log after command
du_enabled && du_after=$(repo_du)
date_after=$(date)
date_after=$(date +%s)
duration=$(human_duration "$date_before" "$date_after")

if du_enabled
Expand Down