25#ifndef FBCPP_BACKUP_MANAGER_H
26#define FBCPP_BACKUP_MANAGER_H
28#include "ServiceManager.h"
29#include "fb-cpp-export.h"
51 std::optional<std::uint64_t> length;
85 backupFiles.emplace_back(value, std::nullopt);
94 if (!backupFiles.empty() && !backupFiles.back().length)
95 throw std::invalid_argument{
"Cannot add a backup file with length after a backup file without length"};
97 backupFiles.emplace_back(value, length);
106 backupFiles = {{value, std::nullopt}};
115 backupFiles = {{value, length}};
124 return verboseOutput;
132 verboseOutput = std::move(value);
141 return parallelWorkers;
149 parallelWorkers = value;
154 std::string database;
155 std::vector<BackupFileSpec> backupFiles;
157 std::optional<std::uint32_t> parallelWorkers;
169 std::optional<std::uint64_t> length;
178 return databaseFiles;
186 databaseFiles = {{value, std::nullopt}};
195 databaseFiles = {{value, length}};
204 databaseFiles.emplace_back(value, std::nullopt);
213 if (!databaseFiles.empty() && !databaseFiles.back().length)
215 throw std::invalid_argument{
216 "Cannot add a database file with length after a database file without length"};
219 databaseFiles.emplace_back(value, length);
236 backupFiles.emplace_back(value);
245 backupFiles = {value};
271 return verboseOutput;
279 verboseOutput = std::move(value);
288 return parallelWorkers;
296 parallelWorkers = value;
318 std::vector<DatabaseFileSpec> databaseFiles;
319 std::vector<std::string> backupFiles;
320 bool replace =
false;
322 std::optional<std::uint32_t> parallelWorkers;
323 std::optional<ReplicaMode> replicaMode;
332 using ServiceManager::ServiceManager;
Executes backup and restore operations through the Firebird service manager.
Represents options used to run a backup operation through the service manager.
const std::vector< BackupFileSpec > & getBackupFiles() const
Returns the configured backup file specifications.
const std::string & getDatabase() const
Returns the database path to be backed up.
BackupOptions & addBackupFile(const std::string &value, std::uint64_t length)
Appends a backup file path with a split length.
BackupOptions & addBackupFile(const std::string &value)
Appends a backup file path.
BackupOptions & setBackupFile(const std::string &value)
Replaces the backup file paths with a single path.
BackupOptions & setVerboseOutput(ServiceManager::VerboseOutput value)
Sets the verbose output callback.
BackupOptions & setParallelWorkers(std::uint32_t value)
Sets the requested number of parallel workers.
BackupOptions & setDatabase(const std::string &value)
Sets the database path to be backed up.
const ServiceManager::VerboseOutput & getVerboseOutput() const
Returns the verbose output callback.
const std::optional< std::uint32_t > & getParallelWorkers() const
Returns the requested number of parallel workers.
BackupOptions & setBackupFile(const std::string &value, std::uint64_t length)
Replaces the backup file paths with a single path and split length.
Represents options used to run a restore operation through the service manager.
RestoreOptions & setReplace(bool value)
Sets whether the target database should be replaced.
bool getReplace() const
Returns whether the target database should be replaced.
RestoreOptions & setDatabase(const std::string &value)
Sets the database path to be restored.
RestoreOptions & addBackupFile(const std::string &value)
Appends a backup file path.
const std::optional< std::uint32_t > & getParallelWorkers() const
Returns the requested number of parallel workers.
const ServiceManager::VerboseOutput & getVerboseOutput() const
Returns the verbose output callback.
RestoreOptions & setDatabase(const std::string &value, std::uint64_t length)
Sets the database path to be restored with a split length.
const std::vector< DatabaseFileSpec > & getDatabaseFiles() const
Returns the configured database file specifications.
RestoreOptions & addDatabaseFile(const std::string &value, std::uint64_t length)
Appends a database file path with a split length.
RestoreOptions & setReplicaMode(ReplicaMode value)
Sets the replica mode.
RestoreOptions & setParallelWorkers(std::uint32_t value)
Sets the requested number of parallel workers.
const std::optional< ReplicaMode > & getReplicaMode() const
Returns the replica mode.
RestoreOptions & setVerboseOutput(ServiceManager::VerboseOutput value)
Sets the verbose output callback.
RestoreOptions & addDatabaseFile(const std::string &value)
Appends a database file path.
RestoreOptions & setBackupFile(const std::string &value)
Replaces the backup file paths with a single path.
const std::vector< std::string > & getBackupFiles() const
Returns the backup file paths.
Represents a connection to the Firebird service manager.
std::function< void(std::string_view line)> VerboseOutput
Function invoked when a verbose service output line is available.