0

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.

Cudos
  • 539
  • 2
  • 7
  • 18

2 Answers2

1

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`
malcolmpdx
  • 2,300
  • 1
  • 16
  • 12
1

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.