MySQL backup PHP helper

My job requires a lot of manually database backups. And believe me, it slowly becomes a nightmare.

So, I started looking for an easy way to backup the database. In my Google searches I found this article: http://davidwalsh.name/backup-mysql-database-php, which is very good.

You can add this code in a page, paste your database credentials, setup a cron job and that’s it, you have the database backups.

My question is: What if you want to backup your MySQL database manually from time to time?

You need to login into your hosting administration panel (usually CPanel)> PhpMyAdmin > Your database > Export database. It’s a long way, I know, that’s why I made a database backup helper.

Attached to this post you can find a php page that will help you backup your database in a very easy way ( I have to mention that I used some of David Walsh’s code from the article mentioned above to generate the database backup file).

The steps you need to follow to fully backup your database using this php helper:

  1. upload the file to your server (for security reasons don’t make the link public to anyone)
  2. complete the form with your database credentials (see the picture below)
  3. press “Backup Database”
  4. wait for the file to be created
  5. save the file to your computer (while saving, the file is automatically deleted from the server)
  6. that’s it! easy huh :)

If you want to skip entering the credentials every time, just fill these variables in the php code of the file:


$db_host = '';
 $db_name = '';
 $db_user = '';
 $db_pass = '';

and the form fields will be auto completed.

VERY IMPORTANT: MAKE SURE YOU UPLOAD THE FILE IN A SECURE FOLDER,  NOT PUBLIC. I STRONGLY RECOMMEND YOU UPLOAD IT TO A .HTACCESS PASSWORDED FOLDER.

Since this is the first version of the file, it is not that advanced, but I’m planning to improve it and make it better.Future updates will also bring PostgreSQL support.

Known issue: The backup files are not deleted so you must delete them manually or you can modify the php code to delete the files.

ANOTHER VERY IMPORTANT THING: WHEN USING THE DATABASE BACKUP PAGE, NO DATA IS SENT TO MY WEBSITE, EMAIL OR ANY OTHER HOST. THE ONLY THING THAT IS LOADING FROM MY WEBSITE IS THE LOGO.

Feel free to ask any questions, suggest features or modify the script. As I mentioned above, the script will be permanently improved.

Download links:

Download v0.1 zip

Download v0.1 tar

2 Replies to “MySQL backup PHP helper”

    1. At this moment the only way is to modify the code.
      As I stated, this helper can be much improved and in the near future I will improve it.

      And if you asked, the first improvement I’ll make it will be with your request. I will let you know when it will be ready.

Leave a Reply

Your email address will not be published. Required fields are marked *