# Verifying last successful rsync (solved)

## Bigun

I'm performing offsite back of my home media center, and was wondering how I would capture the last date/time of the last successful rsync.Last edited by Bigun on Thu Sep 11, 2014 12:05 pm; edited 1 time in total

----------

## freke

I got these in /var/log/emerge.log

```
1395109202: Started emerge on: Mar 18, 2014 03:20:01

1395109202:  *** emerge  --sync

1395109202:  === sync

1395109202: >>> Synchronization of repository 'gentoo' located in '/usr/portage'...

1395109202: >>> Starting rsync with rsync://[2607:f740:0:29:230:48ff:fef8:a064]/gentoo-portage

1395109296: === Sync completed with rsync://[2607:f740:0:29:230:48ff:fef8:a064]/gentoo-portage

1395109296:  *** terminating.

```

Just need to convert the epoch timestamp to something a bit more human-readable  :Smile: 

----------

## John R. Graham

It's a standard *nix Julian second number. The following little Awk script will interpret it for you:

```
{

    print strftime("%F %R:%S", $1) gensub("[[:digit:]]+(:.*)$", "\\1", 1);

}
```

But to see the exact timestamp of the Portage tree at time of last --sync, see "/usr/portage/metadata/timestamp.chk".

- John

----------

## Bigun

Not an emerge sync... an actual rsync between two machines.

----------

## John R. Graham

Sorry; missed that. I don't think rsync stores that information. Instead, I think it calculates the differences between source and destination on the fly.

 - John

----------

## Bigun

 *John R. Graham wrote:*   

> Sorry; missed that. I don't think rsync stores that information. Instead, I think it calculates the differences between source and destination on the fly.
> 
>  - John

 

Is it possible then to detect a 0 exit status then report the time into a file?

----------

## John R. Graham

Sure.  :Wink:  In Bash,

```
if command-line-for-your-rsync ; then

    date >some-file

fi
```

- John

----------

## Bigun

 *John R. Graham wrote:*   

> Sure.  In Bash,
> 
> ```
> if command-line-for-your-rsync ; then
> 
> ...

 

Not the cleanest solution, but one can assume if it exits with status 0, it's all good.

*edit*

The resultLast edited by Bigun on Fri Sep 12, 2014 11:19 am; edited 2 times in total

----------

## steveL

 *Bigun wrote:*   

> The result

 

Heh, that is sweet :-)

Do you rsync the pi from a qvm-emu chroot on your machine? (not for backups I mean, for building.)

----------

## Bigun

 *steveL wrote:*   

>  *Bigun wrote:*   The result 
> 
> Heh, that is sweet 
> 
> Do you rsync the pi from a qvm-emu chroot on your machine? (not for backups I mean, for building.)

 

The system works by my media center at home pushing the data via a SSH rsync session to a remote location where my Pi and an external drive are.  I basically perform the sync, if it's successful, it puts the date/time into a file, then performs a sync on that folder so the Pi knows the sync was successful.  I then have a Python script checking that file every 30 seconds, then display the info on the LCD.

The buttons on the front can scroll through memory usage, CPU usage, CPU temp, and free space on the external drive.  Another set of buttons simply scrolls through the colors that are available through the backlight.  And a fifth button is there to either refresh the data with a push, or if it's held in, will shutdown the Pi.

----------

