Is ignore option enabled after-date?

I wanted to do incremental backups using tar. I made a full backup in 2012-04-08, and later I wanted to back up all files created or modified after this 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 some time, I realized that tar is archiving files that, as I know, have not changed since the last backup. I checked their modification dates and should not be included.

I do not believe, so I did 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/

Obviously tar ignores the -N, --newer, and - after-date options. He archived both files, although the one I named OLD was created with a timestamp until 2012.

How can I help myself with this?

+3
source share
1 answer

Date format must be

tar --newer 20120408

for newer files than April 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
+8
source

All Articles