Question: Short question: I have two dynamically generated tar archives (so they have different timestamps), how can I compare them, ignoring any different in time?

Backgrounds...

I am doing some backup, in which I use a script to generate things that needs to be backed up, put them in to a directory, then tar the directory and keep several old versions. The backup script needs to run every 30 minutes to make sure we don't lose hours of work.

Now I realize that there are periods of time that the data doesn't change, so it doesn't make sense to store duplicates of the same thing over and over again. I would like to compare the archives before saving. My attempt was to run `cmp newdata.tar.gz olddata.tar.gz` and only store `newdata.tar.gz` if it contains new data. Apparently that didn't work, because there are different timestamps.

Answer: 
One option is to use a backup tool like `backup2l`, that can be configured to any level of differential backups and any number of full backups. `backup2l` is ran as a cronjob in any frequency you like and it is configured by setting some values to its conf file. It is actually a wrapper for tar or afio, it keeps file listings with hashes for finding changes and provides an easy way to get status or restore a file by date.

A second option is to use a version control system such as `cvs`, `svn`, `git` etc. Setup a cronjob that will make automatic commits (and maybe daily tagging). Based on the vcs choice, you may need some scripting to add new files or remove old ones. 

For a frequency of every half hour, I'd recommend the vcs option. But you can combine the two by using `backup2l` (or any other backup tool) to also backup the vcs repository (redundancy of backups is always good).
Do the files inside the archives change, or are just new ones added?

If you only add files, and don't change any, try something like this:

```
tar ztf olddata.tar.gz | sort > tmpfile1
tar ztf newdata.tar.gz | sort > tmpfile2
diff tmpfile{1,2} > /dev/null
if test $? -eq 0
then
  echo ignore newdata.tar.gz
else
  echo keep olddata.tar.gz
fi
rm tmpfile{1,2}

```

Note the absence of `v` from the tar table of contents commands.

If you just want to skip archives with identical contents, add a `v` to the mix, as in:

```
tar ztvf olddata.tar.gz | sort > tmpfile1

```

and so on.