0

I have written a bash script for backing up my sql database.

#!/bin/bash
#START
DBNAME=test_uat
host=127.0.0.1
username=root
DATE=`date +"%Y%m%d"`
SQLFILE=spen_db-${DATE}
mysqldump -u $username -p $DBNAME --routines | gzip -9  > $Backup_path.sql.gz
#END

I get a .sql.gz file which is part file.

Unable to download the same, it says corrupt archive.

  • 1
    I debug cases like this as follows: store the command to be executed in a variable: stmt="mysqldump --opt $username -p ...etc", see what it looks like: echo $stmt and then execute it: $stmt. You will be able to figure out where the error is. – Jos Nov 29 '16 at 8:36
  • Thanks for the tip @Jos, i found there was /r which i was able to remove using sed cmd and now i get .gz file around some 1gb which is part file...y so...im not able to download the same – Sushivam Nov 29 '16 at 9:01
0

It should not matter if you have mapped 127.0.0.1 to mysite.com, the most common problem I have had with Mysql backup script for 20 years it that there are no spaces allowed between "-u" and the username, and between "-p" and the password.

| improve this answer | |
  • I guess u may be right, but thats the actual problem for my scenario? i tried removing the space between -u and username, i face the same issue – Sushivam Nov 29 '16 at 7:12
  • It doesn't allow a space after -p, but a space after -u doesn't seem to matter. – Jos Nov 29 '16 at 8:30
0

It seems that combination 'your_user'@'localhost' doesn't exist in the table mysql.user
or you enter wrong password

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.