Avatar of jackal077
jackal077
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Mysqldump backup script and crontab error

Hi,

I've got the following mysqldumb backup scritpt:

#/bin/sh
mysqldump -u username -pmypass --all-databases > DB.sql
gzip DB.sql
NOW=$(date +"mysql-backup-%H%M-%d-%m-%y")
mv DB.sql.gz /home/user/BACKUPS/"$NOW.gz"

It works fine when I start it manually. When i put it in crontab, I get the following error:

mysqldump: Couldn't execute 'SHOW TRIGGERS LIKE 'data\_29'': Got error 28 from storage engine (1030)

I reasearched that error 28 means there is not enough storage. That was the case but i free up some space and I'm still getting this error. Also under crontab the backup file is nearly half the size.
MySQL Server

Avatar of undefined
Last Comment
jackal077

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rory Clerkin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Tomas Helgi Johannsson

Hi!

To take a backup and compress the file in one line of code do this
#!/bin/sh
backfile=$(date +"mysql-backup-%H%M-%d-%m-%y")
myuser=yourusername
mypass=yourpassw
cd /home/user/BACKUPS
mysqldump -u $myuser -p$mypass --all-databases | gzip -9 > $backfile.sql.gz

Open in new window


This will compress your backup as much as possible on the fly and save storage.

Regards,
      Tomas Helgi
jackal077

ASKER
Hi,
yes, I must have missed the !. Cron runs under root. I didn't realize I had to define the path inside the script. That was it. Thx.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck