vendredi 9 janvier 2015

Compressing multiple files in different folders without folder structure


Currently I create a copy of my log files like this:



# tar -cvzf /var/www/vhosts/example.com/httpdocs/myfiles.tar.gz
/var/www/vhosts/http://ift.tt/1DCy0VI
/var/www/vhosts/example.com/httpdocs/app/tmp/logs/error.log
/var/log/mysqld.log
/var/log/messages
/var/log/httpd/access_log
/var/log/httpd/suexec_log
/var/log/httpd/error_log
/var/log/sw-cp-server/error_log


But this creates a tar files with the directory structure. To avoid folder structure it seems like I should make cd for each file, so all files will be saved to tar file without subfolders. (Also there is a problem with tar.gz files, tar command doesn't permit to update archieve file, if file is compressed)


But in this case there will be multiple files with same name, for example 2 file with name access_log.


So I need to change destination log file name.

For example



/var/www/vhosts/http://ift.tt/1DCy0VI to -var-www-vhosts-example.com-logs-access_log

/var/log/httpd/access_log to -var-log-httpd-access_log


Is this possible with script ?



Aucun commentaire:

Enregistrer un commentaire