[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does --newer work for -x?

On 12/30/16 15:53, Scott Wheeler wrote:
On Dec 31, 2016, at 00:29, Graham Percival <gperciva@tarsnap.com> wrote:
On Sat, Dec 31, 2016 at 12:19:09AM +0100, Scott Wheeler wrote:
bela: /tmp/foo> sudo tarsnap -xvf test --newer "Jan 1, 2016"

--newer is only specified for working with -c:

Ah, odd, missed that when scanning the docs.  Most options that aren't supported in a given mode return an error.  Since tarsnap does do some conditional processing (even if erroneously) and neither prints an error nor exits with a non-zero status, I kept playing with it.

Hmm, the code which checks options for validity thinks they're ok in [cxt] modes (bsdtar.c):
        if (bsdtar->newer_ctime_sec || bsdtar->newer_ctime_nsec)
                only_mode(bsdtar, "--newer", "cxt");
        if (bsdtar->newer_mtime_sec || bsdtar->newer_mtime_nsec)
                only_mode(bsdtar, "--newer-mtime", "cxt");

and that seems be be what the code does (read.c):
                 * Exclude entries that are too old.
                st = archive_entry_stat(entry);
                if (bsdtar->newer_ctime_sec > 0) {
                        if (st->st_ctime < bsdtar->newer_ctime_sec)
                                continue; /* Too old, skip it. */
                        if (st->st_ctime == bsdtar->newer_ctime_sec
                            && ARCHIVE_STAT_CTIME_NANOS(st)
                            <= bsdtar->newer_ctime_nsec)
                                continue; /* Too old, skip it. */

So I think the man page is wrong here.

As for the precise formats accepted... this is some very historical
date/time parsing code, so I'd assume that "201601010000" would be
parsed as the start of January 1, 2016 (see `touch -t`).  Looking at
the code, it's clear that a variety of other formats can be parsed;
but I don't think the exact set is documented anywhere...

(BTW, for your exact use case I think the --keep-newer option might
do what you want much far less aggravation?)

Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid