Design

Storage mechanisms are implemented via the BackupClientInterface and RestoreClientInterface. To add custom storage mechanisms you need to implement these methods. These interfaces are designed to be as simple as possible while being completely abstract to allow for any theoretical storage mechanism.

BackupClientInterface

The BackupClientInterface implements the entire backup flow including the resuming from a previously terminated backup. Of note is the BackupClientInterface.State which is the data structure that is returned when any previously existing backup for that key exists. This is provided to BackupClientInterface.backupToStorageSink indicating whether the backup being performed is a new backup or resuming from a previous one with the retrieval of the current state being defined by BackupClientInterface.getCurrentUploadState.

Note that when implementing BackupClientInterface you do not need to handle the corner cases regarding the contents of the byte string when resuming/suspending/terminating, this is automatically handled for you. Essentially you just need to handle how to store/push ByteString into the storage of your choice.

RestoreClientInterface

The RestoreClientInterface implements restoration from an existing backup. Implementing this is quite simple, you need to define RestoreClientInterface.retrieveBackupKeys which returns all valid keys to restore (i.e. don’t include currently in progress backup keys) and RestoreClientInterface.downloadFlow which is a pekko-stream Flow that takes a String which is the key and outputs the content of that key.

The source code for this page can be found here.