A Simple Linux Shell Script To Export WordPress MySQL Database

Here is an example of a simple shell script that will ask for the password of MySQL user that has access to the particular WordPress MySQL database to be exported and dump it into the the directory specified . (To know what are Linux shell scripts and how to make them, please refer to the basic shell scripting tutorials we have) :

TS is how the date format is stored for the database exported, in this case it will be YYYY-MM-DD format. This is then appended to prefix “blog” (can be the name of WordPress blog/domain name for clarity) and entire format is stored in DBBKPNAME which is what the exported database will look like in the specified directory (/srv/dbdump) in this case.

Copy the above script in a text editor like nano, vi etc and replace yourdatabasename and username as needed (These should be MySQL database and user names). Then save it as something meaningful like wpdb_exp.sh