I am creating a tar.gz
file containing some files and folders as follows:
/bin/tar cfz /usr/local/backups/mybackup-${DATENAME}.tar.gz
/usr/local/backups/db-${DATENAME}.sql.gz
/usr/local/tomcat/webapps/MyApp/myapp_folder
/usr/local/tomcat/myapp.properties
But the paths are stored as usr/local
that is without /
. tar
also gives message to remove first /
but file is created.
Now when I transfer this file to some other system and want to uncompress it:
tar -zxvf mybackup-2011-APR-18.tar.gz
It creates usr
directory in current directory.
How can I compress and uncompress the archive and get my files back into original folders (in /usr
tree instead of ./usr
)?