Wednesday, August 12, 2009

tar help (zip up a linux dir and all files and subdirs)

use this to zip up linux dirs, files, folders, subdirs, etc.

tar -cvzpffilename.gz {source dir or files wildcard}

Example:
tar -cvzpfpublic_html_backup_08122009_plinkgolf.gz public_html

where:
-f - whatever follows the f is the filename, so public_html_backup_08122009_plinkgolf.gz is the tarball/zip file name in this case.
-v indicates verbose listing of command output.
-c indicates create a new tar ball file.
-z indicates use gzip.
-p indicates preserve all permissions of underlying files/dirs being zipped.
public_html - is the name of the top level folder I am zipping including all its subfolders and files underneath it

Have a nice day!

Oops - almost forgot, to explode/unzip the zip file in the current directory, just type:

tar -xvf nameofzipfile.gz

No comments: