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

DATE=`date +"%Y%m%d"`
mysqldump -u $username -p $DBNAME --routines | gzip -9  > $Backup_path.sql.gz

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

It should not matter if you have mapped 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

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.