1

So I have a script that does attempts to create a sql file on the server, and then zips that file up. I'm having an issue where the GZip call is being executed before the file is written. The odd thing is that when I run this on my VM instance it's totally fine. But when I test it on one of the servers, nothing but fail.

 echo "Backing up $DB..."
 $PROG_MYSQLDUMP -u $USERNAME -p${PASSWORD} -h $HOST $DB $IGNORES > ${DEST_FILE}

 echo "Zipping file...${DEST_FILE}"
 $PROG_GZIP $DEST_FILE

The only idea I have is to add a check before the GZip call is made that checks for the file and goes on only is it's there else after like X checks fails. I don't like this solution. Is there something I'm missing to get the script to wait on its own?

Thanks.

1
  • Whatever you are seeing I guarantee you that $PROG_GZIP will not execute until $PROG_MYSQLDUMP has exited, meaning the file has been written (or not). Commented Oct 31, 2011 at 18:20

2 Answers 2

4

There's no way the gzip program could get started before the dump was written. Anyway, why aren't you piping the dump in gzip? This should save time and temporary disk space. Also, it would reduce the load on the disks.

$PROG_MYSQLDUMP -u $USERNAME -p${PASSWORD} -h $HOST $DB $IGNORES |
$PROG_GZIP > $DEST_FILE.gz
Sign up to request clarification or add additional context in comments.

1 Comment

Haha, almost simultaneously. Have a +1 :)
4

Or a pipeline? Evades the temporary file.

$PROG_MYSQLDUMP -u $USERNAME -p${PASSWORD} -h $HOST $DB $IGNORES | $PROG_GZIP >  ${DEST_FILE}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.