Basics – mminfo, savetime and greater than/less than

Take a basic mminfo query, add someone not familiar with how NetWorker stores and works with dates/times, and you have instant chaos*. In this post I want to help people who are just starting out with mminfo understand how it works with dates.

So let’s look at a basic query that tends to cause a lot of confusion:

# mminfo -q "client=archon,savetime<=2 weeks ago"

As a long-term NetWorker user, and implementation consultant/support consultant, not to mention a long term member of the NetWorker mailing list, this question seems to come up fairly frequently. The output appears “broken” – rather than being “savetime less than or equal to two weeks ago”, we instead get all backups for the client archon where the savetime is greater than or equal to two weeks ago.

‘Huh?’ I hear you ask.

Indeed, this is oft-used as an example of how “broken” NetWorker is. In fact, the real state is far more prosaic.

NetWorker stores and works with times as seconds since the(/an) epoch. When you supply dates to NetWorker – either in the fuzzy format above, or as a literal date string, it converts that date into a timestamp of seconds since the(/an) epoch. (You can if you want find out what a savetime is in seconds, rather than an interpreted date any time you wish in mminfo by choosing a report specification of ‘nsavetime’.)

So if you then think of the query:

# mminfo -q "client=archon,savetime<=2 weeks ago"

It has a different meaning. You’re actually asking NetWorker:

  • Convert ‘2 weeks ago’ into seconds offset from ‘now’. Let’s call that Z.
  • Give me all the backups for the client ‘archon’ where the savetime is less than or equal to Z.

If you don’t like to think of it as all referring to seconds since an epoch, there’s another, perhaps simpler way of thinking about it – that being:

  • Treat “<” as meaning before.
  • Treat “>” as meaning after.

Thus, in this scenario, the query:

# mminfo -q "client=archon,savetime<=2 weeks ago"

Can be interpreted to mean, “give me all backups of the client archon taken before two weeks ago”.

You’re obviously welcome to use whichever interpretation you feel makes more sense – seconds/math or before/after – it doesn’t really matter which. Once you get the hang of this though mminfo will make a lot more sense.

* I’ve unfortunately seen someone who got < and > wrong (and didn’t check their results) relabel all tapes in a tape library that had backups younger than 3 months, rather than older than 3 months. Hence, ‘chaos’ is an appropriate term.

7 thoughts on “Basics – mminfo, savetime and greater than/less than”

  1. Great blog. Lots of good technical networker info. Thanks!
    Where is “ago” as in “2 weeks ago” documented? I certainly didn’t see it in nsr_getdate(3).
    I believe nsr_getdate mentions relative time is [number] unit.

    There also seems to be a difference in the below queries
    mminfo -q “pool=pool1, savetime<4 week"
    mminfo -q "pool=pool1, savetime<4 week ago"

    1. Hi Brett,

      It’s certainly referenced in the mminfo documentation; if you check that, you’ll notice it used multiple times in the examples given.

      As to the discrepancy you encountered – I’d been using “ago” for so long now that I’ve not run the alternative for years.

      Doing a few basic tests, it appears to me that “savetime<X week" actually gets ignored by NetWorker. E.g., here's what I got from:

      [root@nox ~]# mminfo -q “pool=Staging,savetime<3 week" -otR | head -5
       volume        client       date      size   level  name
      Staging-01.RO  nox              11/25/2009 38 MB 9  index:archon
      Staging-01     nox              11/25/2009 38 MB 9  index:archon
      Staging-03.RO  archon    11/25/2009   4  B    incr  /Volumes/TARDIS/Yojimbo
      Staging-03     archon    11/25/2009   4  B    incr  /Volumes/TARDIS/Yojimbo
      

      That’s clearly (as of the time I write this reply) from today. However, if I run it with the “3 weeks ago”, I get what I should get:

      [root@nox ~]# mminfo -q “pool=Staging,savetime<3 weeks ago" -otR | head -5
       volume        client       date      size   level  name
      Staging-01.RO  loki      11/04/2009 497 KB    incr  /
      Staging-01     loki      11/04/2009 497 KB    incr  /
      Staging-01.RO  loki      11/04/2009   4  B    incr  /boot
      Staging-01     loki      11/04/2009   4  B    incr  /boot
      

      So it looks to me that we have an instance of mminfo interpreting “3 week ago” differently to what we’d expect (I.e., it’s coming back as “now”, somehow), but “3 weeks ago” is the correct invocation.

      Cheers,

      Preston.

  2. Hi Preston!
    From some testing I did, it looks like “3 week” will be converted to a time 3 weeks in the future of the current time while “3 week ago” will be converted to a time 3 weeks in the past of the current time.
    I still think “ago” should be documented in the nsr_getdate(3) man page. A couple of examples in the mminfo(1m) man page isn’t documentation. Even the mminfo man page says time attributes are specified in nsr_getdate(3)

    Regards,

    brett

  3. hi , is it possible to find out all information abt data which has retention more than 2 years?

    I failed using

    mminfo -q ‘ssretent>01/01/14’ -avot
    mminfo -q ‘ssretent> 2 years’ -avot

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.