only stop server to dump database

This commit is contained in:
Thies Lennart Alff 2025-01-03 21:34:22 +01:00
parent 3540b40bfc
commit d23b5a4a4d
Signed by: lennartalff
GPG key ID: 4EC67D34D594104D

View file

@ -41,6 +41,18 @@ class ForgejoManager(backup_manager.BackupManager):
return False
return True
def stop_server(self):
cmd = "docker compose stop server"
try:
result = subprocess.run(
cmd, shell=True, text=True, check=True, capture_output=True
)
except subprocess.CalledProcessError as e:
self._gotify.send_subprocess_error("Failed to stop server", error=e)
return False
return True
def start_database(self):
cmd = "docker compose up -d db"
try:
@ -81,10 +93,7 @@ def main():
config = read_config()
os.chdir(config["common"]["BACKUP_DOCKER_DIR"])
backup_manager = ForgejoManager(config)
if not backup_manager.stop_all_services():
exit(1)
if not backup_manager.start_database():
backup_manager.start_all_services()
if not backup_manager.stop_server():
exit(1)
if not backup_manager.dump_database():
backup_manager.start_all_services()