getting the mdate of a file

Dan Nelson dnelson at allantgroup.com
Tue Jul 15 22:38:17 PDT 2003


In the last episode (Jul 15), David Bear said:
> I'd like to run tar using a data incremental.  For example, if I run
> tar today like this:
>   tar cvf /dev/nsa0 /home > home.catalog
> 
> I end up with a listing of all files tarr'ed in home.catalog.  Then
> the next day I'd like to run tar but only have tar select files that
> were changed since home.catalog was written.  Tar has --newer DATE
> option but I would like to set the DATE according to the last
> modified time of the home.catalog.
> 
> So, question 1 is how do I get the last mod date of a file?  

>From the tar infopage:

`--newer=DATE'
`--after-date=DATE'
`-N'
     When creating an archive, `tar' will only add files that have
     changed since DATE.  If DATE begins with `/' or `.', it is taken
     to be the name of a file whose last-modified time specifies the
     date.

> Question 2 is, is there a better way that I'm missing?

What I did when I used tar for backups was to use the
listed-incremental option, which tells tar to create a list of
filenames and timestamps, and on subsequent runs, only back up files
that differ from the listfile.  Worked very well.  To do a full backup,
just delete the listfile before running tar.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list