Class BackupRunner

java.lang.Object
ai.chatur.cortex.spring.backup.BackupRunner

public class BackupRunner extends Object
Takes a backup of the assertions store and uploads it to S3.

All of the backup feature's behavior lives here, in a plain object with no Spring or Quartz dependency, so it can be exercised directly; BackupJob is a thin scheduler adapter over it, and CortexBackupAutoConfiguration is the only thing that knows how it is scheduled.

The local backup file is deliberately left in place after a successful upload: the copy in S3 is a copy, not a move, so a bucket misconfiguration can never be silently destructive. Backups therefore accumulate beside the store, and pruning them is left to whatever manages that volume.

Failures propagate rather than being logged and swallowed — a backup that silently stopped working would be worse than one that fails loudly, and BackupJob is where the decision to report rather than retry is made.

  • Constructor Summary

    Constructors
    Constructor
    Description
    BackupRunner(ai.chatur.cortex.core.store.BackupService backupService, software.amazon.awssdk.services.s3.S3Client s3Client, String bucket, String keyPrefix)
    Creates the runner.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    run()
    Takes a backup and uploads it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BackupRunner

      public BackupRunner(ai.chatur.cortex.core.store.BackupService backupService, software.amazon.awssdk.services.s3.S3Client s3Client, String bucket, String keyPrefix)
      Creates the runner.
      Parameters:
      backupService - takes the TDB2 snapshot
      s3Client - the client the snapshot is uploaded through
      bucket - the bucket to upload to
      keyPrefix - prepended verbatim to the backup's file name to form the object key
  • Method Details

    • run

      public void run()
      Takes a backup and uploads it.

      The object key is cortex.backup.key-prefix followed by the file's name. TDB2 already makes that name unique per backup (backup_<yyyy-MM-dd_HHmmss>.nq.gz), so an upload never overwrites an earlier one.

      Throws:
      RuntimeException - if the backup cannot be taken or the upload fails