Retrospect EA - Last Backup Completed

burdett
Contributor II

Hi,
Anyone managing Mac clients being backed up by Retrospect? I need a Extension Attribute to report the last date a client was backed up.

I found a logfile /private/var/log/retroclient.log with the backup date and time. Here is an example of the log file entry;
1450142118: SopsSetBackupDates: last:2015-12-14@17:0 next:2015-12-15@17:0

I made an attempt at the following script but didn't quite get the results I wanted. The result was, result>last:2015-12-14@17:0</result I just want the date, 2015-12-14.

#!/bin/sh
if [ -f /private/var/log/retroclient.log ];then
lastBackupTime=`cat /private/var/log/retroclient.log | grep -w "SopsSetBackupDates: last" | awk '{print $3}'`
echo "<result>$lastBackupTime</result>"
else
echo "<result></result>"
fi
4 REPLIES 4

davidacland
Honored Contributor II
Honored Contributor II

You could use sed to remove characters after and including the @ or perhaps just use cut if the date value length stays the same when the days and months are single digits.

thoule
Valued Contributor II

A fun awk parameter is -F which allows you to specify the delimiter (what separates fields). By default its a space, but you add this to the end of your line...

|awk -F@ '{print $1}'

Kedgar
Contributor

People are still using Retrospect? I haven't heard of that in a very long time!

burdett
Contributor II

Incase anyone was interested the final version of this script, I ended up using the following;

#!/bin/sh
if [ -f /private/var/log/retroclient.log ];then
lastBackupTime=`tail -r /private/var/log/retroclient.log | grep -m 1 "SopsSetBackupDates" | awk '{print $2, $3}'| awk -F@ '{print $1}' | sed 's/.*://g'`
echo "<result>$lastBackupTime</result>"
else
echo "<result></result>"
fi