Skip to content
4.6

How can I have the MySQL backup emailed automatically?

If it is not too large, you can have it emailed to yourself automatically via the cron jobs option in DirectAdmin.

  1. Open DirectAdmin via My Products (the 'DirectAdmin' button) and log in
  2. Choose Cron Jobs
  3. Enter for example 45 for the minute, for example 5 for the hour, and asterisks for the rest so that it runs every day.
  4. Create 2 cron jobs. Have the 2nd cron job start an hour later, for example
  5. Cron job 1:
    1. mysqldump --routines -u <databasegebruikersnaam> -p'<wachtwoord>' <databasenaam> > ${HOME}dbbackup.sql
      1. Replace <databasegebruikersnaam> with the username of the database. You can find it via DirectAdmin by clicking on the database
      2. <wachtwoord> The password of the database user in question. If you do not know it, simply create a new user for that database.
      3. <databasenaam> The full database name, so in the format user_name
      4. You can also change the name dbbackup.sql to a different name if you want to back up multiple databases.
  6. Cron job 2:
    1. For the command, enter:
      1. /usr/bin/mutt -s "backup" -a /home/<user>/dbbackup.sql -- <mailadres> < /dev/null
      2. Replace <sqlnaam> with the name of the database
      3. Replace <user> with the username you use to log in to DirectAdmin
      4. Replace <mailadres> with the email address the SQL file should be sent to.
      5. You can replace the text Backup with your own text (this is the subject of the email)
  7. Then choose Add.

ATTENTION: Make sure you fill in the minute and day, so NO asterisks. Running it every minute could cause major problems.

Was this article helpful?

← Back to General hosting

One moment…

Set up your domains

For each domain, arrange the nameservers, the link to your hosting and who becomes the owner.

Loading your domains…