This script allow you to doing Auto backup to your MySQL DB.
I run it as a cron job on Windows/Ubuntu servers to make sure we have a latest version of DB daily.
- Easy to install and configure
- Can be run as a cron job on Windows and Ubuntu servers
- Create it as a composer package (Coming Soon)
- Supports multiple database servers (Coming Soon)
- Supports different database engines (Coming Soon)
- Supports automatic restoration of backups (Coming Soon)
- Supports email notifications (Coming Soon)
- Supports OneDrive integration (Coming soon)
- Supports cloud storage (Coming Soon)
- Supports encryption of backups (Coming Soon)
I plan to continue developing and enhancing the PHP Pure Script for Auto Backup MySQL DB in the future. Below is a list of features I plan to add in the future:
-
Easy to install and configure
-
Can be run as a cron job on Windows and Ubuntu servers Customizable backup frequency and destination
-
Create it as a composer package: Currently, the script is not available as a composer package. In the future, I plan to create it as a composer package to make it easier for users to install and use the script.
-
Implement support for multiple database servers: Currently, the script only supports backing up databases on a single server. In the future, I plan to add support for backing up databases on multiple servers.
-
Add support for different database engines: The script currently only supports MySQL databases. In the future, I plan to add support for other database engines such as PostgreSQL and SQL Server.
-
Improve error handling: I plan to improve the script's error handling to make it more robust and user-friendly.
-
Add support for automatic restoration of backups: Currently, the script only supports creating backups. In the future, I plan to add support for automatically restoring backups in case of data loss.
-
Add support for email notifications: I plan to add the ability to send email notifications to users when a backup is created or when an error occurs.
-
Improve documentation and examples: I plan to improve the documentation and examples provided in the repository to make it easier for users to get started with the script.
-
Add support for cloud storage: Currently, the script only supports saving backups to a local folder. In the future, I plan to add support for other cloud storage providers such as OneDrive, Google Drive and Dropbox.
-
Add support for encryption of backups: I plan to add the ability to encrypt backups to protect sensitive data. This roadmap represents our current plans for the development of the PHP Pure Script for Auto Backup MySQL DB, but it is subject to change as I receive feedback and suggestions from users.
I welcome any feedback or ideas you have for improving the script, and I look forward to continuing to develop and enhance it in the future.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need to have PHP installed on your machine.
- Clone this repo
- Open
config.php
file - Edit the following variables to match your DB information and backup folder path:
$host = "localhost"; // host name
$user = "root"; // user name
$password = ""; // password
$database = "test"; // database name
$backupFolder = '/backups/'; // backup folder name
$hasOneDriveFolder = true; // if you have a onedrive folder to save the backup file
$fileName = $database .'-' . date('Y-m-d').'-'. time() . '.sql';
You can run it with below command:
php backup.php
You can setup cron job on Windows using schedual with below steps:
- Open Task Scheduler
- Click Create a Basic Task
- Enter a name for the task
- Select "Run whether user is logged on or not"
- Check "Run with highest privileges"
- Click on "Triggers"
- Click New
- Select "Daily"
- Click OK
- Click on "Actions"
- Click New
- Select "Start a program"
- Enter the path to php.exe in the "Program/script" field
- Enter the path to backup.php in the "Add arguments" field
- Click OK
You can setup cron job on Ubuntu using crontab with below steps:
-
Open terminal
-
Run crontab
crontab -e
-
Add the following line to the end of the file:
0 0 * * * php /path/to/backup.php
-
Save and exit
This project is licensed under the MIT License - see the LICENSE.md file for details