We run daily backups of our MySQL server. Using the following script:
[ ! -d "${DEST}" ] && mkdir -p "${DEST}"
FILE=${DEST}/mysql-live.${NOW}-$(date +"%T").tar.gz.bz2
# get around error
mysqldump --single-transaction -u $MUSER -h $MHOST -p$MPASS DB | bzip2 -k -v > $FILE
Now, when I try to extract with tar xvjf I get an error. It will unarchive with bunzip2 to a tar.gz file, but when I try to extract using tar xvf, xzvf, gunzip, it shows not a gzip archive. However, if I try to rename it to just a tar, it will show not a tar archive.
I'm slightly confused here as I'm running out of options, if anyone has any ideas. That would rock. It's on CentOS.
Best Answer
Your command
says dump a database and pipe the output to bzip2 which should write it's stdout to $FILE.
The contents of stdin will be compressed and written to for example a.tar.gz.bz2. This doesn't create either a tar archive or a gzip compressed tar archive (.tar.gz), is simply creates a .bz2 compressed archive with a confusing name.
When you try to extract the contents of the archive (for reasons unknown) you attempt to use the tar utility and to you, unexpectedly get an error message, probably something like
Which is correct because the file is not a bzip compressed gzip compressed tar archive. You probably need something like
As you are not generating either a tar archive or a gzip compressed archive you should probably not make .tar.gz part of the filename as, as you have found it just creates confusion.