[CentOS] tar with -N option still picking up old files

Fri Mar 27 12:52:16 UTC 2009
Les Mikesell <lesmikesell at gmail.com>

John Doe wrote:
> From: Akemi Yagi <amyagi at gmail.com>
>> On Thu, Mar 26, 2009 at 3:16 PM, Neil Aggarwal wrote:
>>> Hello:
>>>
>>> I tried this command to tar up a set of data files
>>> updated since yesterday (The data directory contains
>>> multiple files with varying dates):
>>>
>>> /bin/tar -z -c -N 2009-03-25 -f /tmp/test.tgz data
>>>
>>> When I look at the content of the test.tgz file,
>>> it looks like it copied the content of the entire
>>> directory, not just the newer files.
>>>
>>> I am on CentOS 5.
>> Try --newer-mtime instead of -N.  In my case (CentOS-4 backup
>> machine), the -N option did not work as it's supposed to.  Not sure
>> about tar on CentOS-5 though.
> 
> I like the distinction in the man page...
> 
>        -N, --after-date DATE, --newer DATE
>               only store files newer than DATE
> 
>        --newer-mtime DATE
>               like --newer, but with a DATE
> 
> Translation: --newer-mtime DATE is like --newer DATE, but with a DATE...  ^_^

The difference is supposed to be that --newer-mtime uses mtime and the 
others use ctime for the file timestamp check.

But, there's an old saying that when the code and the documentation 
differ they are probably both wrong...

If you want finer-grained control you should use the 
--listed-incremental FILE option anyway.  If the file doesn't exist, you 
get a full run and the file is created containing a list of directories 
traversed.  If you specify an existing file, you get an incremental 
containing newer files plus everything under directories not listed from 
the previous run - and the file is re-written in place for a next-level 
incremental.  If you want multiple incrementals base from the full you 
have to save a copy of this file before each incremental for subsequent 
use.   This is the only way to catch older files in their new locations 
  under renamed directories - and it also triggers the mode that permits 
the restore option of deleting files that weren't present during the run 
(without it you can run out of space when restoring a series of 
incrementals).

---
   Les Mikesell
    lesmikesell at gmail.com



-- 
   Les Mikesell
    lesmikesell at gmail.com