Skip to content

Commit

Permalink
bareos-fd-postgres: renamed some methods to something more reasonable
Browse files Browse the repository at this point in the history
  • Loading branch information
lluuaapp committed Dec 1, 2022
1 parent ca66f5f commit 98e436c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions core/src/plugins/filed/python/postgres/BareosFdPluginPostgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,19 @@ def restore_object_data(self, ROP):
)
return bareosfd.bRC_OK

def __dbConClose(self):
def close_db_connection(self):
"""
Make sure the DB connection is closed properly. Will not throw if the connection was already closed.
"""
try:
self.dbCon.close()
except pg8000.exceptions.InterfaceError as e:
pass

def closeDbConnection(self):
def complete_backup_job_and_close_db(self):
"""
Call pg_stop_backup() on PostgreSQL DB to mark the backup job as completed.
"""
# TODO Error Handling
# Get Backup Start Date
self.parseBackupLabelFile()
Expand All @@ -475,7 +481,7 @@ def closeDbConnection(self):
+ "CHECKPOINT LOCATION: %s, " % self.labelItems["CHECKPOINT LOCATION"]
+ "START WAL LOCATION: %s\n" % self.labelItems["START WAL LOCATION"],
)
self.__dbConClose()
self.close_db_connection()
self.PostgressFullBackupRunning = False
except Exception as e:
bareosfd.JobMessage(
Expand Down Expand Up @@ -525,12 +531,12 @@ def end_backup_file(self):
return bareosfd.bRC_More
else:
if self.PostgressFullBackupRunning:
self.closeDbConnection()
self.completed_backup_job_and_close_db()
# Now we can also create the Restore object with the right timestamp
self.files_to_backup.append("ROP")
return self.checkForWalFiles()
else:
self.__dbConClose()
self.close_db_connection()
return bareosfd.bRC_OK

def end_backup_job(self):
Expand All @@ -540,10 +546,10 @@ def end_backup_job(self):
especially when job was cancelled
"""
if self.PostgressFullBackupRunning:
self.closeDbConnection()
self.completed_backup_job_and_close_db()
self.PostgressFullBackupRunning = False
else:
self.__dbConClose()
self.close_db_connection()
return bareosfd.bRC_OK

def wait_for_wal_archiving(self, LSN):
Expand Down

0 comments on commit 98e436c

Please sign in to comment.