Jump to content

Backup DB before migration


gebeer
 Share

Recommended Posts

Hi @bernhard,

I usually have a line in my Site module that does a DB backup before the migrations are running

  public function migrate()
  {

    // backup before migrations (not on ddev)
    if (strpos($this->config->httpHost, 'ddev') === false) $this->wire->database->backups()->backup();

...

I moved my migrations from the migrate method to the new phantastic config migration structure in site/RockMigrations. So much cleaner to have each field/template migration defined in a separate file :-)

But: since the migrations now do not live in Site module, the DB backup is not being triggered because there are no changes to that file anymore.

Long story short: Is there a setting in $config->rockmigrations that will do automatic backups befor each migration on the live server? Couldn't find anything related in the docs, the GH wiki or even searching the string "backup" in the RockMigrations module folder.

Could this feature be added or how do handle this?  

Link to comment
Share on other sites

6 hours ago, gebeer said:

But: since the migrations now do not live in Site module, the DB backup is not being triggered because there are no changes to that file anymore.

I'm not sure about this. That should only be the case on regular runtime migrations, but when doing a modules refresh all migrations should fire.

6 hours ago, gebeer said:

Long story short: Is there a setting in $config->rockmigrations that will do automatic backups befor each migration on the live server? Couldn't find anything related in the docs, the GH wiki or even searching the string "backup" in the RockMigrations module folder.

Could this feature be added or how do handle this? 

I'm using RM Deployments and they perform a backup before each deployment. Is that what you are looking for?

Link to comment
Share on other sites

7 minutes ago, bernhard said:

I'm not sure about this. That should only be the case on regular runtime migrations, but when doing a modules refresh all migrations should fire.

Ah, thank you. That make sense. Will prioritize my Site module migration so that the backup is created before the config migrations kick in.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...