Let's say you have a gzipped tarball that contains all your logs from /var/log with fully qualified paths. One thing to remember is that tar will always remove any leading / from all paths it processes. This means if you ran the tar command as follows:
tar zcf /tmp/logs.tar.gz /var/log
you will have a gzipped tarball containing files such as:
var/log/httpd/access.log
var/log/httpd/error.log
var/log/messages
var/log/dmesg
With this in mind, if you want to extract just your web server log files located in var/log/httpd, you can use the following commandline:
tar zxf /tmp/logs.tar.gz --wildcards 'var/log/httpd/*'
The quotes are necessary so the wildcard doesn't get extrapolated. That command will result in the var/log/httpd directory structure being created in your current dir and you will find that directory populated with the access.log and error.log files.
No comments:
Post a Comment