bobbingwide / oik-batch

Batch interface to WordPress
https://www.oik-plugins.com/oik-plugins/oik-batch
GNU General Public License v2.0
0 stars 0 forks source link

Add automatic database backup for in situ PHPUnit testing #14

Open bobbingwide opened 7 years ago

bobbingwide commented 7 years ago

This is belt and braces stuff. When running the native WP_UnitTestCase class for WordPress 4.7 the database is magically emptied. This is the exact opposite of what's required for In situ testing. To protect against this we could add some logic to automatically backup the environment's database if it hasn't already been backed up that day.

bobbingwide commented 7 years ago

On 7th March 2016 I wrote a simple backup.bat file

@echo (C) Copyright Bobbing Wide 2016
rem See also the unstarted backup-qw plugin
rem 
rem  mysqldump -u root -p oikplug_wp993 > oikplug_wp993-0225-dropped.sql
setlocal
cd \backups-qw\qw\sqldumps

rem mm/dd/yyyy
rem echo %date%
set mydate=%date:~6,4%%date:~0,2%%date:~3,2%

echo %1-%mydate%.sql
pause
mysqldump -u root -p %1 > %1-%mydate%.sql
endlocal
bobbingwide commented 7 years ago

The simple backup produced using mysqldump with only the basic parameters

mysqldump -h %s -u %s --password=%s %s --result_file=%s

does not contain enough information to rebuild a database from scratch. It's missing: