matrix-synapse: restart service on restore #1630
@ -63,5 +63,10 @@
|
|||||||
output = machine.succeed("runuser -u postgres -- /run/current-system/sw/bin/psql --csv -c \"SELECT datdba::regrole FROM pg_database WHERE datname = 'test'\"")
|
output = machine.succeed("runuser -u postgres -- /run/current-system/sw/bin/psql --csv -c \"SELECT datdba::regrole FROM pg_database WHERE datname = 'test'\"")
|
||||||
owner = output.split("\n")[1]
|
owner = output.split("\n")[1]
|
||||||
assert owner == "test", f"Expected database owner to be 'test', got '{owner}'"
|
assert owner == "test", f"Expected database owner to be 'test', got '{owner}'"
|
||||||
|
|
||||||
|
# check if restore works if the database does not exist
|
||||||
|
machine.succeed("runuser -u postgres -- dropdb test")
|
||||||
|
machine.succeed("${nodes.machine.clanCore.state.postgresql-test.postRestoreCommand}")
|
||||||
|
machine.succeed("runuser -u postgres -- /run/current-system/sw/bin/psql -d test -c '\dt' >&2")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
@ -147,6 +147,7 @@ in
|
|||||||
ENCODING = "UTF8";
|
ENCODING = "UTF8";
|
||||||
OWNER = "matrix-synapse";
|
OWNER = "matrix-synapse";
|
||||||
};
|
};
|
||||||
|
clan.postgresql.databases.matrix-synapse.restore.stopOnRestore = [ "matrix-synapse" ];
|
||||||
|
|
||||||
clanCore.facts.services =
|
clanCore.facts.services =
|
||||||
{
|
{
|
||||||
|
@ -146,6 +146,7 @@ in
|
|||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
pkgs.util-linux
|
pkgs.util-linux
|
||||||
pkgs.zstd
|
pkgs.zstd
|
||||||
|
pkgs.gnugrep
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
while [[ "$(systemctl is-active postgresql)" == activating ]]; do
|
while [[ "$(systemctl is-active postgresql)" == activating ]]; do
|
||||||
@ -167,7 +168,9 @@ in
|
|||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p "${folder}"
|
mkdir -p "${folder}"
|
||||||
runuser -u postgres -- dropdb "${db.name}"
|
if runuser -u postgres -- psql -d postgres -c "SELECT 1 FROM pg_database WHERE datname = '${db.name}'" | grep -q 1; then
|
||||||
|
runuser -u postgres -- dropdb "${db.name}"
|
||||||
|
fi
|
||||||
runuser -u postgres -- pg_restore -C -d postgres "${current}"
|
runuser -u postgres -- pg_restore -C -d postgres "${current}"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user