Is tar ignoring --after-date option?

backup, tar

Solution

Your date format must be

tar --newer 20120408

for newer files than Apr 8, 2012. No "-"!

Or you can use

TWODAYSAGO=`(date --date '2 days ago' --rfc-3339=seconds)`
tar -cz  --newer-mtime="${TWODAYSAGO}"  -f bakfile.tgz  /dir_to_backup

Problem

I wanted to make an incremental backup with tar. I have made a full backup on 2012-04-08 and later I wanted to backup all files created or changed after that date. So I did something like this: ``` cd /directory/I/wanted/to/back/up tar --newer 2012-04-08 -cvnf "/backup/dir/$(date +%F).tar" ``` After a while I realised that tar is archiving files that I know have not changed since last backup. I checked their modification dates and they should not be included. I coudn't believe it so I made a little test: ``` cd ~ mkdir test cd test touch -t 201101010000 OLD touch NEW cd .. tar -N 2012-01-01 -cvf test.tar ./test/* tar -tf test.tar ls -o ./test/ ``` It clearly seems that tar is ignoring the -N, --newer and --after-date options. It has archived both files, even though the one I named OLD was created with a timestamp before 2012. How can I help myself with this?

Original source