From aa034ae421dacebff07a1bd71f93f9bf855f1844 Mon Sep 17 00:00:00 2001 From: guvra Date: Tue, 5 Mar 2024 11:41:34 +0100 Subject: [PATCH] Use a readonly connection to create the dump --- CHANGELOG.md | 4 ++++ src/Dumper/MysqlDumper.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c7f613..80237f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## WIP + +- Use a readonly connection to create the dump ([#121](https://github.com/Smile-SA/gdpr-dump/pull/121)) + ## [4.2.0] - 2024-03-05 [4.2.0]: https://github.com/Smile-SA/gdpr-dump/compare/4.1.1...4.2.0 diff --git a/src/Dumper/MysqlDumper.php b/src/Dumper/MysqlDumper.php index e5eff147..3c216ede 100644 --- a/src/Dumper/MysqlDumper.php +++ b/src/Dumper/MysqlDumper.php @@ -90,6 +90,9 @@ private function getDumpSettings(DumperConfig $config): array $settings['exclude-tables'] = $config->getTablesBlacklist(); $settings['no-data'] = $config->getTablesToTruncate(); + // Set readonly session + $settings['init_commands'][] = 'SET SESSION TRANSACTION READ ONLY'; + return $settings; } }