How to Reset MySQL database with time limit using php
I have a demo website for the users. It contain database with few tables. I want to reset the entire database with time frame using PHP.
How can I truncate all the tables every hour?
Truncating every table wouldn't work in this case because some of the tables will contain initial configuration data.
I would set up the basic system exactly as you want it. Then do a one off database dump and a tarball back up of the moodledata directory.
Also create a file in moodledata called
old_climaintenance.html with a message for users while the site is offline.
Then set up a bash script to go through these steps
climaintenance.htmlto let users know its offline.
- Drop the database
- Delete the contents of the moodledata directory - except old_climaintenance.html
- Restore the tarball into moodledata
- Recreate the database from the data dump
Then set up a cron job to run the bash script every hour.
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]