MySQL Auto Backup

There are servers those don't have any hosting control panels and hosting websites and databases in it. Here I am describing a simple way to set up an auto backup solution for the databases configured on the server.

Please follow the steps below:

  1. Create a directory to store the backup files on the server. Here we are using /backup.

  2. Create a small shell script with the DB username, password, backup location, backup name etc. 
    mysqldump -u root -pdbpass dbname>/backup/dbname-`date '+%Y-%m-%d'`.sql

    Here, you need to replace the username with the actual username and also provide the correct DB name and password instead of 'dbpass'. 

  3. Now we need to make it as an executable file:
    chmod +x
  4. It is better to run it using a cronjob in order to take automatic backups.
    #crontab -e
    0 0 * * *  sh /

    This will run once in a day. If you need to take more backups a day, you can adjust the cronjob accordingly. 


  • mysql backup
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...

Domainkey installer in cPanel

You can use the following cPanel script to install domainkey for an account...

Email issues :: Common Troubleshooting Steps

Here I will discuss some common errors and their solution: We are using a mail relay setup for...