View previous topic :: View next topic |
Author |
Message |
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Wed Sep 10, 2014 2:59 pm Post subject: Verifying last successful rsync (solved) |
|
|
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 |
|
Back to top |
|
|
freke l33t
Joined: 23 Jan 2003 Posts: 977 Location: Somewhere in Denmark
|
Posted: Wed Sep 10, 2014 3:25 pm Post subject: |
|
|
I got these in /var/log/emerge.log
Code: | 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 |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Sep 10, 2014 3:40 pm Post subject: |
|
|
It's a standard *nix Julian second number. The following little Awk script will interpret it for you: human-readable-emerge-log.awk: | {
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 _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Wed Sep 10, 2014 3:50 pm Post subject: |
|
|
Not an emerge sync... an actual rsync between two machines. |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Sep 10, 2014 3:52 pm Post subject: |
|
|
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 _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Wed Sep 10, 2014 4:12 pm Post subject: |
|
|
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? |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Sep 10, 2014 4:19 pm Post subject: |
|
|
Sure. In Bash, Code: | if command-line-for-your-rsync ; then
date >some-file
fi | - John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Thu Sep 11, 2014 3:11 pm Post subject: |
|
|
John R. Graham wrote: | Sure. In Bash, Code: | if command-line-for-your-rsync ; then
date >some-file
fi | - John |
Not the cleanest solution, but one can assume if it exits with status 0, it's all good.
*edit*
The result
Last edited by Bigun on Fri Sep 12, 2014 11:19 am; edited 2 times in total |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Thu Sep 11, 2014 5:20 pm Post subject: |
|
|
Heh, that is sweet :-)
Do you rsync the pi from a qvm-emu chroot on your machine? (not for backups I mean, for building.) |
|
Back to top |
|
|
Bigun Advocate
Joined: 21 Sep 2003 Posts: 2196
|
Posted: Fri Sep 12, 2014 12:33 pm Post subject: |
|
|
steveL wrote: |
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. |
|
Back to top |
|
|
|