Create a backup schedule for Database with Cron Job
QuanTriMang - To backup the database for WordPress, there are many plugins that can help you do this. Some of them only back up the database for you, while there are also things to help backup the entire directory in WordPress. If you are a long-time WordPress user, you will realize that the plugins are unreliable. With thousands of reasons why they work every other day - unstable. It may be because they are not compatible with the version of WordPress you have just upgraded, or there is a conflict with certain plugins that have been installed or even because the database is too large for the plugin's handling capability.
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
$ 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
You should read it
- Instructions for installing WordPress on the Vitual Server with Cloud9
- 11 security tips for WordPress blogs
- Which platform is better for WordPress.com and WordPress.org?
- Why is WordPress free?
- 5 best e-commerce WordPress plugins
- How to set up WordPress for local development in Linux
- 5 mistakes everyone mistakenly thinks about WordPress
- 30 best free WordPress presentation plugins (2018)
May be interested
- How to create a registration app using Python and databasepython has excellent database support built into its standard library, so you can create and interact with a database without having to rely on an external framework like django orm.
- How to use Google Calendar to schedule classesmanaging the school schedule can be a complicated task. however, you can use google calendar to simplify it.
- MS Access - Lesson 4: Create a new databaseyou can create a new database from scratch or from the wizard database.
- How to create a copy of data in MS SQL Serverthis is the guide to create backup for database in ms sql server.
- How to schedule Twitter poststwitter has the same post scheduling feature as you schedule on facebook fanpage. users can schedule posts any time they want,
- Create and restore backups with VMware vSphere Data Recoveryin this article, i will show you how to create a backup schedule for a virtual machine, run a backup, and then restore the virtual machine from backup.
- How to Create a Windows Azure SQL Databasethis wikihow article show you how to create a windows azure sql database. also it shows you how to connect to database from your app. log in to your windows azure management portal.
- Instructions to schedule FaceTime on iPhoneone of the new features on facetime for the new ios upgrade is setting up facetime scheduling with friends or with certain groups.
- Create Database in MongoDBthe use database_name command in mongodb is used to create the database. this command will create a new database, if it does not exist yet, otherwise, this command will return the existing database.
- How to Schedule an Event in Outlookmicrosoft outlook now has the option to schedule right in the interface without having to use another application. after you schedule a meeting or any calendar in outlook, the application will send a notification when the schedule is close, or according to the user's settings.