Feature to restore database implemented

This commit is contained in:
Tobias Herre 2023-10-13 21:08:47 +02:00
parent a6a149a156
commit 1cd5758f05
1 changed files with 23 additions and 5 deletions

View File

@ -4,11 +4,13 @@
bundle agent vimbadmin(cfg)
{
vars:
"r" int => randomint(1,5),
handle => "rand_assigned";
classes:
"vimbadmin_restore_db_file" expression => isvariable("cfg[restore_db_file]");
vimbadmin_restore_db_file::
"vimbadmin_restore_db" expression => fileexists("$(cfg[restore_db_file])");
vars:
"vsettings[resources.doctrine2.connection.options.driver]" string => "'$(cfg[db_driver])'";
"vsettings[resources.doctrine2.connection.options.dbname]" string => "'$(cfg[db_name])'";
"vsettings[resources.doctrine2.connection.options.user]" string => "'$(cfg[db_user])'";
@ -88,11 +90,17 @@ files:
commands:
"!mysql_$(cfg[db_name])_admin_exists"::
"(!mysql_$(cfg[db_name])_admin_exists)&(!vimbadmin_restore_db)"::
"cd $(cfg[install_dir]) && ./bin/doctrine2-cli.php orm:schema-tool:create "
contain => wmde_cmd_useshell,
handle => "vimbadmin_db_initialized",
depends_on => {"vimbadmin_appini_edited"};
"(!mysql_$(cfg[db_name])_admin_exists)&vimbadmin_restore_db"::
"mysql -u $(cfg[db_user]) -p$(cfg[db_pass]) -h$(cfg[db_host]) $(cfg[db_name]) < $(cfg[restore_db_file])"
contain => wmde_cmd_useshell,
depends_on => {"vimbadmin_appini_edited"};
vimbadmin_reconfigure::
"/bin/sh"
@ -121,6 +129,16 @@ methods:
"any" usebundle => mysql_table_exists(@(cfg),"admin");
reports:
# "VIMBADMIN $(cfg[restore_db_file])";
# "vimbadmin_restore_db_file"::
# "RESTORE_DB_FILE";
# "vimbadmin_restore_db"::
# "RESTORE_DB";
# "(!mysql_$(cfg[db_name])_admin_exists)&vimbadmin_restore_db"::
# "Should restore db";
}