[pmg-devel] [PATCH pmg-api 1/2] backup: reorder tables in order of dependency
Stoiko Ivanov
s.ivanov at proxmox.com
Thu Feb 22 13:40:50 CET 2024
Currently we dump the tables manually and print the relevant
DDL statements into the dump-file before copying the data.
The complete backup and dump specific tables part would probably be
best replaced by an appropriate `pg_dump` invocation - but as a
stop-gap measure reorder the tables in order of their dependencies.
Noticed while adding a foreign key constraint on 2 new tables
(objectgroup_attribute and rule_attribute) and running backup+restore.
Reported-by: Dominik Csapak <d.csapak at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/PMG/Backup.pm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm
index 5891afb..ab7e628 100644
--- a/src/PMG/Backup.pm
+++ b/src/PMG/Backup.pm
@@ -90,18 +90,18 @@ sub dumpdb {
eval {
$dbh->begin_work;
# read a consistent snapshot
$dbh->do("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
+ dump_table($dbh, 'objectgroup', $ofh, 'objectgroup_id_seq', 'id');
+ dump_table($dbh, 'object', $ofh, 'object_id_seq', 'id');
dump_table($dbh, 'attribut', $ofh);
dump_table($dbh, 'objectgroup_attributes', $ofh);
- dump_table($dbh, 'rule_attributes', $ofh);
- dump_table($dbh, 'object', $ofh, 'object_id_seq', 'id');
- dump_table($dbh, 'objectgroup', $ofh, 'objectgroup_id_seq', 'id');
dump_table($dbh, 'rule', $ofh, 'rule_id_seq', 'id');
+ dump_table($dbh, 'rule_attributes', $ofh);
dump_table($dbh, 'rulegroup', $ofh);
dump_table($dbh, 'userprefs', $ofh);
# we do not save the following tables: cgreylist, cmailstore, cmsreceivers, clusterinfo
};
my $err = $@;
--
2.39.2
More information about the pmg-devel
mailing list