]> git.proxmox.com Git - pmg-api.git/commitdiff
backup: reorder tables in order of dependency
authorStoiko Ivanov <s.ivanov@proxmox.com>
Thu, 22 Feb 2024 12:40:50 +0000 (13:40 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 22 Feb 2024 13:28:22 +0000 (14:28 +0100)
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@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
src/PMG/Backup.pm

index 5891afb7af8fa104e059b4a73c8581d67005e1c1..ab7e6285a40c2385d22fbcb4e32eb7d1fed0028f 100644 (file)
@@ -93,12 +93,12 @@ sub dumpdb {
        # 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);