Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I run drush quickstart-create I get an on screen report during the process:
"You are about to DROP your 'testqstrt_local' database and then CREATE a new one. Do you want to continue? (y/n): y"
Is it possible to change the default behaviour to dump any existing database to a SQL file at a defined path, similar to the '.old' folder that is created for any existing website files?
I've been playing with this for a little while but can't find a solution.
Cheers,
Crom
Comments
Comment #1
MichaelCole CreditAttribution: MichaelCole commentedHi Crom, this is an interesting idea. Yes, it should do this, and would be easy to accomplish inside the drush command.
In the meantime, here's what I do in a shell script. This script backups up the database if the file doesn't exist, and restores it if it does:
Room for improvement, but this is a good start if you want to write a shell script yourself.
Cheers,
Mike
Comment #2
Crom CreditAttribution: Crom commentedThanks Mike - I used the commands in your script to get what I wanted done which is great.
I've used a function within your quickstart.inc file and tweaked it to do the db check and backup. Some of the lines are specific to my requirements/setup but in case it's useful here it is - I'm sure it can ben improved but it works so happy for the moment ;-)
Can't work out how to configure that Drush y/n check but I'm only starting with drush...
Cheers,
Crom
Comment #3
MichaelCole CreditAttribution: MichaelCole commentedHi you might be able to change:
drush_backend_invoke("-r $codepath sql-dump --gzip --result-file=$logfilename");
to:
drush_backend_invoke("-y -r $codepath sql-dump --gzip --result-file=$logfilename");
Haven't tested it.
Comment #4
MichaelCole CreditAttribution: MichaelCole commentedComment #5
kenorb CreditAttribution: kenorb commentedIs the --gzip argument is supported? I can't find it in --help?
Comment #6
MichaelCole CreditAttribution: MichaelCole commentedUuuuuuhhhh.... Neither can I D-: It probably doesn't exist and is ignored. Examples online pipe through gzip. Mea culpa.
Comment #7
DjebbZ CreditAttribution: DjebbZ commentedIf I'm not mistaking, the "DROP database and CREATE a new one" stuff comes from the
drush site-install
command. Should be better to file an issue there to change the options of the command, so thatdrush qc
just have to rely on it instead of "forking" it. I'm pretty sure there was already an issue in Drush about not DROPing the database but only the tables (found it : #1105514: site-install - Never try to drop an existing database. Just drop tables.). Drush folks may be happy about adding an option to back it up before.Comment #8
kenorb CreditAttribution: kenorb commentedDrupal 5 and Drupal 6 is no longer officially supported. If you think this issue is still relevant for 8.x, feel free to re-open.