0

I created a backup.sh in /var/www/cronjobs/ where every other cronjobs are:

mysqldump --user root --password=mypass12--opt MYDATABASE \
    > /home/balint/db/db-`date +%Y-%m-%d`.sql

in the /etc/crontab I specified the cron just like my other cronjobs:

*/2 * * * * root wget -q -O- http://mydomain.com/cronjobs/backup.sh

Not a single file is created in /home/balint/db/ I created the db folder manually. And I can enter mysql and phpmyadmin with the user root and the password mypass12. The */2 is for testing only, of course.

What am I missing?

2 Answers 2

0

The wget command will get the script from mydomain.com, but it does not execute it. So it is no surprise that it's acting as if the script is not being run, because it isn't.

added in response to comment:

If "all your cronjobs" are written like that and are working, then you are using some non-standard cron which you didn't tell us about. I just tested a job in /etc/crontab as you described on Ubuntu 13.04. It behaved as documented and didn't pass the stdout of the cmd portion of the job as input to another shell.

Have you looked in /var/log/syslog for any diagnostics?

1
  • I use the wget command with all my cronjobs and they are all working fine.
    – erdomester
    Aug 3, 2013 at 10:42
0

First of all backup your mysql dump using the command in the backup script.

mysqldump --user root --password=mypass12--opt MYDATABASE > /home/balint/db/db-`$(date +"%d-%m-%Y")`.sql 

and then append it with scp to transfer being generated to the remote location

scp /home/balint/db/db-`$(date +"%d-%m-%Y")`.sql you@yourip

for a passwordless login make sure to add the public key of the machine in the remote machine where you want to upload the database dump see the below link

SSH passwordless login

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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