New in version 6.1.0: See the new features.

Switch audit database

audit_switch_database()

Switch audit database

The audit database can be “switched” so that the files can be archived and stored if desired.


SYNTAX

  • sage/srep:

    audit_switch_database(server, “AuditDb”)

    Note: server can be a server name string, an opened !file on the server or an opened database on the server.


  • KfLib* (DNet, Java and Cpp):

    Server.auditSwitchDatabase(AuditDb)


  • SQL Engine (sql command and ScODBC):

    AUDIT SWITCH DATABASE “AuditDb”


Functionality

  • All pending audit writes will be queued

  • Creates the archive location: $SCULPTOR/audit/auditDb/archive/date_time

  • Close the auditDb files: auditrecord, auditfields and transactions

  • Move the files to the archive location: auditDb/archive/date_time

    • The relocation service can be used (scsfr). But take into account that the destination location must be on the SAME file system for the movement to be quick!!!

  • If the database is enabled:

    • Recreate new audit* and transaction files (empty)

    • Check all the server threads, and for each thread that has a transaction open, mark the transaction to be rewritten into the new transaction file if that transaction is used.

  • When finish, continue to process the audit command queue. We’re back into normal operation.

The return value is the created archive directory name (relative to auditDb dir), in case of errors an empty string is returned and the audit database is disabled.


EXAMPLE

To switch the default audit database:

tmp.archiveDirectory = audit_switch_database("localhost", "default")

RELATED TOPICS

Audit service

Audit functions