Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an identical gzip of the same file?

I have a file, its contents are identical. It is passed into gzip and only the compressed form is stored. I'd like to be able to generate the zip again, and only update my copy should they differ. As it stands diffing tools (diff, xdelta, subversion) see the files as having changed.

Premise, I'm storing a mysqldump of an important database into a subversion repository. It is my intention that a cronjob periodically dump the db, gzip it, and commit the file. Currently, every time the file is dumped and then gzipped it is considered as differing. I'd prefer not to have my revision numbers needlessly increase every 15m.

I realize I could dump the file as just plain text, but I'd prefer not as it's rather large.

The command I am currently using to generate the dumps is:

mysqldump $DB --skip-extended-insert | sed '$d' | gzip -n > $REPO/$DB.sql.gz

The -n instructs gzip to remove the filename/timestamp information. The sed '$d' removes the last line of the file where mysqldump places a timestamp.

At this point, I'm probably going to revert to storing it in a plain text fashion, but I was curious as to what kind of solution there is.

Resolved, Mr. Bright was correct, I had mistakenly used a capital N when the correct argument was a lowercase one.

like image 950
Danny Avatar asked Mar 20 '09 18:03

Danny


People also ask

What is the difference between ZIP and gzip?

The most important difference is that gzip is only capable to compress a single file while zip compresses multiple files one by one and archives them into one single file afterwards. Thus, gzip comes along with tar most of the time (there are other possibilities, though).

Does gzip keep original file?

The gzip program compresses and decompresses files on Unix like system. You need to pass the -c or --stdout , or --to-stdout option to the gzip command. This option specifies that output will go to the standard output stream, leaving original files intact.


1 Answers

The -N instructs gzip to remove the filename/timestamp information.

Actually, that does just the opposite. -n is what tells it to forget the original file name and time stamp.

like image 51
Sean Bright Avatar answered Oct 11 '22 02:10

Sean Bright