I am using a Debian 7 Server. I created a shell script to be executed by crontab to save a mysqldump every day.
mysqldump *database* -u *mysql-user* -p*mysql-password* > /backup/mysql_backup/*filename*.sql
If typed directly on the command line, everything works fine. But if I execute the shell script itself (./backup.sh), I get no resulting file, but no error. The folder hat rights 777, the shell script is executable. I didn't even try to put the script into the crontab, when the script doesn't even work executed on the command line.
Does anybody know what to do?
#!/bin/bash
. You can try#!/bin/bash -x
to see what bash is doing. – Jonathan Ben-Avraham May 9 '15 at 20:17*
should be there and what*
you added to indicate metavariables. For example, writemysqldump mydatabase -u foo -pswordfish > /backup/mysql_backup/mydatabase.backup
. Also the permissions 777 are wrong — that's probably not the cause of the script not working, but you do need to fix that. One of 755 or 700 or 775 or 770 or 750 is right, it's up to you to determine what the permissions should be. – Gilles 'SO- stop being evil' May 9 '15 at 22:07/backup/mysql_backup/
that matches*filename*.sql
? How about a unique filename that includes date and time? – ott-- May 9 '15 at 23:28echo $?
afetrmysqldump
– PersianGulf May 10 '15 at 3:45