Zipping

Good Morning,

I'd like to archive an old user's files in the home directory on Solaris 9

Will this work?

cd home
tar -zcvf jsmitharchive.tar.gz jsmith/

---------- Post updated at 09:37 AM ---------- Previous update was at 09:33 AM ----------

Also- is the last

/

necessary (after jsmith)

cd home
tar -zcvf jsmitharchive.tar.gz ./jsmith

i.e. archive the directory 'jsmith' which is below the directory I'm in now '.'

OK Thanks!

That's interesting. I've only seen that used when running an application or script while I'm in the directory- not when something is a "target" of a command. Could I also do

tar -zcvf jsmitharchive.tar.gz /home/jsmith

without

cd home

?

Yes, you could but look up the difference between relative and absolute pathing.

If you use /home/jsmith then you can (normally) only restore it to that location, whereas, if you archive it with a relative name '.' you can restore it anywhere.

So when your user reports that he has lost a file you can restore the archive in some completely different location WITHOUT overwriting his current files. That's why most pro's always use relative pathnames.

Solaris tar does not support the GNU option z to send it through gzip . Instead use

cd home
tar cvf - jsmith | gzip -c > jsmitharchive.tar.gz 

Remember also that tar extracts files to the path they were archived from, so if you use

tar cvf archive.tar /home/jsmith

and then extract the archive it will overwrite a new /home/jsmith (GNU versions of tar strip the leading '/' to stop this from happening).

No.

Andrew