Skip to main content
3 of 7
added 6 characters in body

If you really dont have tar available, you can use gzip to create a backup of a directory, but maybe it is not exactly what you're expecting for...

First you will need to copy your directory to another name, if you dont want to keep the original directory untouchable.

#cp -a etc etc-my-gzip-alone-backup

Second, you will compress all the files on the directory recursively(-r).

#gzip -r etc-my-gzip-alone-backup

Now lets take a look inside the etc-gzip-alone-backup. You will not have a single file etc-compressed.gz as you are expecting for, but a lot gziped files recursively. But it is not good to do that with etc because of symlinks...

To uncompress the directory the same logic can be applied with gunzip.

#gunzip -r etc-compressed 

And then your backup still can be restored. Yes the permissions will be preserved (but i think it wont be nice if you have some symlinks, i dont know what will be the gzip reaction to this! I think will be bad, like compressing targets and broking almost everything)

#mv etc-compressed/* etc/ 

The data is recovered now ;-) So yes, you can work only with gzip if tar is broken or if you are dropped to some kind of static shell without tar, but still will be not practical like tar!