Add support for PostgreSQL.

This would need to extend \BackupMigrate\Core\Source\DatabaseSource. To make this easier, take a look at \BackupMigrate\Core\Source\MySQLiSource as an example.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

magick93 created an issue. See original summary.

damienmckenna’s picture

Title: support postgresql » Add support for PostgresQL
Related issues: +#341277: New backup source: PostgreSQL (D7)

There's an existing issue which talks about the functionality for D7.

damienmckenna’s picture

Issue tags: +PostgreSQL
damienmckenna’s picture

Title: Add support for PostgresQL » Add support for PostgresQL (D8)
damienmckenna’s picture

Issue summary: View changes
damienmckenna’s picture

Title: Add support for PostgresQL (D8) » New backup source: PostgresQL (D8)
boehmrya’s picture

Assigned: Unassigned » boehmrya

I'm going to give this a go.

mykola dolynskyi’s picture

Postgre is not supported yet or present in dev branch of module?

boehmrya’s picture

Not currently. I'm working on a patch for this, but it's not quite ready yet.

However, If you think that you can put something together, by all means, go for it.

mykola dolynskyi’s picture

@boehmrya thanks, I will use cloud drive snapshoting while

ruby232’s picture

@boehmrya I am interested in adding postgres support for Drupal 8, how can I collaborate.
I upload a pull request to https://git.drupalcode.org/project/backup_migrate?

damienmckenna’s picture

If you'd like to upload a WIP you need to do it using a patch file, drupal.org doesn't support pull requests yet.

damienmckenna’s picture

Though honestly if you need help with it you could just upload a zip, tgz or other archive of your files, or even just upload the raw PHP files (after you rename them to e.g something.txt as you aren't allowed to upload files with a ".php" extension) and someone can build the relevant patch file for you.

boehmrya’s picture

Assigned: boehmrya » Unassigned
tongadall’s picture

Yes please, as said in #13, upload as you can, we will try build the relevant patch.

damienmckenna’s picture

Version: 8.x-4.x-dev » 5.0.x-dev

Moving 8.x-4.x issues to 5.0.x because the older branch is no longer supported.

off’s picture

Subscribe

damienmckenna’s picture

@OFF: Just so you know, you don't have to post a comment to "subscribe" to an issue, just click the "Follow" link on the right side of the page and you'll get an email any time a comment is posted.

maxasus123’s picture

Status: Active » Needs review
StatusFileSize
new26.46 KB

Hi, i try create plugin for PostgresQL,
But not work for restore.
It can be exported as sql.giz.
but when i restore it got error

InvalidArgumentException: Class "\Drupal\system\Controller\Http4xxController" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core/lib/Drupal/Core/DependencyInjection/ClassResolver.php).
Drupal\Core\Controller\ControllerResolver->createController('\Drupal\system\Controller\Http4xxController:on404') (Line: 69)
Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition('\Drupal\system\Controller\Http4xxController:on404', '/admin/config/development/backup_migrate/settings/destination/backups/private_files') (Line: 85)
Drupal\Core\Controller\ControllerResolver->getController(Object) (Line: 141)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 2) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 2, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 2, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 2, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 2, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 2, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 2, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 2) (Line: 166)
Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber->makeSubrequest(Object, '/system/404', 404) (Line: 122)
Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber->on404(Object) (Line: 109)
Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase->onException(Object, 'kernel.exception', Object)
call_user_func(Array, Object, 'kernel.exception', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.exception') (Line: 219)
Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object, Object, 1) (Line: 91)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
infojunkie’s picture

How do I use this patch?

I have applied it to backup_migrate 5.0.1, and made sure the new files are created in the right places. When I go to Quick Backup at admin/config/development/backup_migrate, I only see in Backup Source the options "Private Files Directory" and "Public Files Directory".

ANSWER: Go to admin/config/development/backup_migrate/settings/source and add a Backup Source of type PostgreSQL Database.

infojunkie’s picture

StatusFileSize
new9.66 KB

I'm submitting a different patch based on my testing of the patch above. The general idea is to avoid hand-generating and hand-importing SQL dumps, relying instead on pg_dump and psql respectively. This reduces the maintenance surface to the minimum, at the cost of introducing a dependency on the official PostgreSQL client binaries.

Also, there are some fixes compared to the first patch:
- The "Default Drupal Database" and "Entire Site" sources work as expected with PostgreSQL as the main database engine
- Any PostgreSQL database can be targeted in addition to the default Drupal database
- The exclude / no-data tables settings are honored

infojunkie’s picture

StatusFileSize
new9.84 KB

Slight amendment to the above patch to capture stderr in case of errors and log it.

damienmckenna’s picture

Version: 5.0.x-dev » 5.1.x-dev

New changes will be added to 5.1.x.

Let's see if the tests work on PGSQL.

damienmckenna’s picture

Status: Needs review » Needs work

The tests aren'y working against PostgreSQL, so it needs a little work.

infojunkie’s picture

Drupal 9 requires PgSQL 10+, but the test config seems to be running D9.4.x against PgSQL 9.5 - hence the error.

I'd be happy to adjust the test config, but I am not familiar with Drupal CI and I can't seem to login to Dispatcher.

damienmckenna’s picture

Fair point. I've started a test run against PHP 8.1 and PostgreSQL 10.12, we'll see how it works.

msxlrd’s picture

StatusFileSize
new460.52 KB

Hi,

I've installed Backup and migrate (5.0 / 5.1.x-dev) on drupal 9.3.19 with PostgreSQL 11.17, using patch from comment #22.

I'm getting an drupal error after I clicked on the button to add additional settings under /admin/config/development/backup_migrate/settings:

Error: Class 'Drupal\pgsql\Driver\Database\pgsql\Connection' not found in Drupal\backup_migrate\Core\Source\PostgreSQLSource->_getConnection() (Zeile 171 in /var/www/html/app/web/modules/contrib/backup_migrate/src/Core/Source/PostgreSQLSource.php)
#0 /var/www/html/app/web/modules/contrib/backup_migrate/src/Core/Source/PostgreSQLSource.php(191): Drupal\backup_migrate\Core\Source\PostgreSQLSource->_getConnection()
#1 /var/www/html/app/web/modules/contrib/backup_migrate/src/Core/Source/PostgreSQLSource.php(138): Drupal\backup_migrate\Core\Source\PostgreSQLSource->query()
#2 /var/www/html/app/web/modules/contrib/backup_migrate/src/Core/Source/DatabaseSource.php(105): Drupal\backup_migrate\Core\Source\PostgreSQLSource->getRawTables()
#3 /var/www/html/app/web/modules/contrib/backup_migrate/src/Core/Source/DatabaseSource.php(73): Drupal\backup_migrate\Core\Source\DatabaseSource->getRawTableNames()
#4 /var/www/html/app/web/modules/contrib/backup_migrate/src/Core/Filter/DBExcludeFilter.php(70): Drupal\backup_migrate\Core\Source\DatabaseSource->getTableNames()
#5 /var/www/html/app/web/modules/contrib/backup_migrate/src/Drupal/Config/DrupalConfigHelper.php(33): Drupal\backup_migrate\Core\Filter\DBExcludeFilter->configSchema()
#6 /var/www/html/app/web/modules/contrib/backup_migrate/src/Form/SettingsProfileForm.php(48): Drupal\backup_migrate\Drupal\Config\DrupalConfigHelper::buildAllPluginsForm()
#7 /var/www/html/app/web/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\backup_migrate\Form\SettingsProfileForm->form()
#8 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
#9 /var/www/html/app/web/core/lib/Drupal/Core/Form/FormBuilder.php(531): call_user_func_array()
#10 /var/www/html/app/web/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\Core\Form\FormBuilder->retrieveForm()
#11 /var/www/html/app/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#12 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#13 /var/www/html/app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#14 /var/www/html/app/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/www/html/app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#16 /var/www/html/app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#17 /var/www/html/app/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /var/www/html/app/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#19 /var/www/html/app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#20 /var/www/html/app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#21 /var/www/html/app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#22 /var/www/html/app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#23 /var/www/html/app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#24 /var/www/html/app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#25 /var/www/html/app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#26 /var/www/html/app/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle()
#27 /var/www/html/app/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#28 {main}

The class Connection in file PostgreSQLSource.php seems to be undefined:

use Drupal\pgsql\Driver\Database\pgsql\Connection as PgsqlConnection;

Besides that it seems to be working with postgres.

Do you have any idea?

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new9.66 KB
new1.36 KB

I don't see why the Connection class needed to be renamed via the "use" statement, does it work without that?

infojunkie’s picture

The patch at #28 works for me, although I was not able to reproduce the error at #27, and I don't understand how the updated patch would solve the missing class error.

puddyglum made their first commit to this issue’s fork.