Table of Contents
Create a Backup Schedule for Database with Cron Job covers the essential facts behind the topic, including what changed, why it mattered, and how it affected users.
The following article will show a solution to improve this problem, which is to replace plugins by using the Cron Job for your server and schedule a daily backup of the database.
Note: The following instructions can be used to backup every database, the only requirement is that you need to use a Linux server to store files.
Steps to Take:
1. Log in to your web server control. If you use cPanel, go to the Cron job icon.

2. You can set the time and frequency of database backup. Under the command field, copy and paste the following command:
Mysqldump --opt -Q -u dbusername --password = dbpassword dbname |gzip > /path-to-store-the-backup-file/db_backup. Sql. Gz
- Replace dbusername with the database user
- Replace dbpassword with the password of the user database
- Replace dbname with the name of the database you need to backup
- Replace path-to-store-the-backup-file with the file path in your host, where you want to save the backup.
Note: In some servers, you may need to put single quotation marks for dbpassword so that it works. For example:
Mysqldump --opt -Q -u dbusername --password = 'dbpassword' dbname |gzip > /path-to-store-the-backup-file/db_backup. Sql. Gz
Email Database for Yourself
Storing the database on the server can take up a lot of your space. You can save this space by sending a backup file to your own email.
1. Download php script here.
2. Extract the. Zip file and download it and open the backup. Php file with a text editor.
3. Change the details in the database:
$ dbhost = "localhost";// usually localhost $ dbuser = "dbuser"; // enter your username database here $ dbpass = "dbpass"; // enter your database password here $ dbname = "dbname"; // enter your database name here $ sendto = "Send To "; // the email address to send the database to $ sendfrom = "Send From "; $ submitubject = "Daily Database Backup"; // the subject of the email $ bodyofemail = "Here is the daily backup of my database.";
4. Save the file and upload the entire folder to your server. Note: This folder includes a. Htaccess file to prevent any access from the browser. If you want to access it from your browser, you can remove the. Htaccess file.
5. In the session of the Cron job in cPanel, enter the following command:
Php -q /path-to-the-php-script-folder/backup. Php
FAQ
What is the main topic of Create a Backup Schedule for Database with Cron Job?
Create a Backup Schedule for Database with Cron Job covers the essential facts behind the topic, including what changed, why it mattered, and how it affected users.
Why is Backup databases important?
The following article will show a solution to improve this problem, which is to replace plugins by using the Cron Job for your server and schedule a daily backup of the database.
What should readers remember about Backup databases?
Note: The following instructions can be used to backup every database, the only requirement is that you need to use a Linux server to store files.
Reader Comments 0
Sign in with email or Google to join the discussion.