Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to have the following backup cycle on Debian Lenny:

Monday   : Full backup
Tuesday  : Differential backup relative to Monday
Wednesday: Differential backup relative to Monday
Thursday : Differential backup relative to Monday
Friday   : Differential backup relative to Monday
Saturday : Differential backup relative to Monday
Sunday   : Differential backup relative to Monday

Right now I use:

tar -czf /tmp/backup/all-sites-$(date +"%F").tar.gz --exclude '*/imagecache/*' --exclude '*/logs/*' /var/www/public_html/  > /tmp/backup/logfile 2>&1

Should I use --after-date or --newer option? If so, what is the syntax for those options?

The examples on Google / MAN pages makes me more confused that enlighten me.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I would use --newer. This checks the ctime, which any action on the files/directories in question will update. So this will catch any changes at all, even permissions changes, which is likely what you want. If you don't care about anything but actual modification of the files/directories, you can use --newer-mtime. On my system at least, --newer and --after-date are synonyms.

As far as syntax, you need to pass in a date string as an argument to the "--newer" flag. I typically do this by creating a file with the date of my last full backup when I do a full, which contains something like "20-Mar" (i.e. "date +%d-%b"), and then using that file to fill in the parameter when using --newer:

--newer `cat /path/to/datefile`
share|improve this answer
add comment

A simpler approach to "--newer" would be this:

tar -cvf archive.tar -N "last Mon" dir_to_be_archived/

This way you won't need to create date files. Note that -N is same as --newer. Surprisingly, the time syntax can be found in the "date" program's info (man) page, not in tar's manual.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.