backdrop-contrib / backup_migrate

Port of the Drupal backup_migrate module to Backdrop
GNU General Public License v2.0
7 stars 14 forks source link

Add combined option to save database and configuration files #112

Closed izmeez closed 11 months ago

izmeez commented 1 year ago

Currently the backup options include separate options to backup the database and configuration files. The only combined option is code, files and database. It would be nice to have another combined option to backup the database and configuration files.

olafgrabienski commented 1 year ago

It would be nice to have another combined option to backup the database and configuration files.

Yep, that would be really nice. I do quite often a manual backup of database and (active) configuration files, e.g. before installing a new module. Not sure about other use cases, but for me it would be most helpful to combine database and only active config files.

izmeez commented 1 year ago

@olafgrabienski I use the demo module for the use case you describe.

argiepiano commented 11 months ago

Good idea. If you have ideas on how to do this, please submit a PR. Otherwise I'll try to explore it in the future.

argiepiano commented 11 months ago

@olafgrabienski, @izmeez, I have added a new source option: Database and active config directory. PR submitted. Can you please test? The new source has an update hook to include the defaults for the new option within any existing profile. You should test this only in a development environment (not in production), since the update will slightly modify the database (updating the table backup_migrate_profiles).

If you are running 8.1, you may also want to patch your installation with #132.

Screen Shot 2023-12-10 at 9 46 15 PM

There is an automatic test failure - that's a fluke that has happened before. I'll rerun the test tomorrow. It's passing in my local. Something is amiss with the GHA test.

olafgrabienski commented 11 months ago

Wow, thank you very much, @argiepiano! I'll test the PR soon.

olafgrabienski commented 11 months ago

@argiepiano I've tested the PR. The combined backup of the (default) database and the active configuration directory works fine.

For the record, as a result of the new backup option I got a file archive called BackdropTest-2023-12-12T09-16-51.db_config.tar.gz. The archive contains the active folder and a database.sql file. If I didn't miss anything, the contents of the combined backup were the same as the results of a separate backup of database and active configuration.

So, works for me, and many thanks again!

olafgrabienski commented 11 months ago

Oh, I guess there is an issue with restoring: To test if the combined backup restores correctly, I added a node and uploaded the backup file. As a result, I got the error Could not perform the restore. and the following explanation:

The database was not restored because the archive did not seem to contain a database backup or was in a format that Backup and Migrate couldn't read

argiepiano commented 11 months ago

@olafgrabienski thanks for testing! CAn you clarify/confirm that you picked "Restore to: Database and active config directory" in the dropdown?

Screen Shot 2023-12-12 at 6 26 02 AM

Also, I'm not sure the functionality to restore backups that contain files and DB actually work through upload - I'll look into this. Can you please also test by backing up to "Manual" and then choosing to restore from "Saved backup" instead of "Upload"?

Screen Shot 2023-12-12 at 6 27 36 AM

Thanks

olafgrabienski commented 11 months ago

Sure! In the dropdown, I did choose "Restore to: Database and active config directory". Just tested again, with the same error. And indeed, while the issue happens with an uploaded file, the "Restore from a saved backup" works fine.

argiepiano commented 11 months ago

@olafgrabienski, I pushed another change that, in my testing, takes care of the problem of restoring from an upload. By the way, I discovered this problem affects also "whole site" restores from uploads, and most like also ALL restores that involve decompressing tar files from uploads. I will fix those later.

If you could test this one again, that'd be great. BTW, another bug: when a restore fails, the uploaded temporary file is never deleted from the file_managed table, which leads to a fatal error if you try to restore from the same file again. To prevent this, go to Content > Manage files, and find and remove any temporary files that may have been left over from previous tests.

argiepiano commented 11 months ago

By the way, there is a test failure that's produced because there is a new option added to the dropdown menu (the new DB and config source). I'll fix that tomorrow.

olafgrabienski commented 11 months ago

@argiepiano Thanks for the updated PR! Restoring the combined backup works perfectly now, both from an upload and from the Manual Backups Directory. Works for me!

PS: I've commented re a file name typo in the PR.

argiepiano commented 11 months ago

Excellent. Thanks for testing! I'll fix the file and class names, and the tests later today and this should be good to go.

argiepiano commented 11 months ago

Merged! Thank you for your help, @olafgrabienski.