25#ifndef FBCPP_BACKUP_MANAGER_H
26#define FBCPP_BACKUP_MANAGER_H
28#include "ServiceManager.h"
50 std::optional<std::uint64_t> length;
84 backupFiles.emplace_back(value, std::nullopt);
93 if (!backupFiles.empty() && !backupFiles.back().length)
94 throw std::invalid_argument{
"Cannot add a backup file with length after a backup file without length"};
96 backupFiles.emplace_back(value, length);
105 backupFiles = {{value, std::nullopt}};
114 backupFiles = {{value, length}};
123 return verboseOutput;
131 verboseOutput = std::move(value);
140 return parallelWorkers;
148 parallelWorkers = value;
153 std::string database;
154 std::vector<BackupFileSpec> backupFiles;
156 std::optional<std::uint32_t> parallelWorkers;
168 std::optional<std::uint64_t> length;
177 return databaseFiles;
185 databaseFiles = {{value, std::nullopt}};
194 databaseFiles = {{value, length}};
203 databaseFiles.emplace_back(value, std::nullopt);
212 if (!databaseFiles.empty() && !databaseFiles.back().length)
214 throw std::invalid_argument{
215 "Cannot add a database file with length after a database file without length"};
218 databaseFiles.emplace_back(value, length);
235 backupFiles.emplace_back(value);
244 backupFiles = {value};
270 return verboseOutput;
278 verboseOutput = std::move(value);
287 return parallelWorkers;
295 parallelWorkers = value;
300 std::vector<DatabaseFileSpec> databaseFiles;
301 std::vector<std::string> backupFiles;
302 bool replace =
false;
304 std::optional<std::uint32_t> parallelWorkers;
Executes backup and restore operations through the Firebird service manager.
void restore(const RestoreOptions &options)
Runs a restore operation using the provided options.
void backup(const BackupOptions &options)
Runs a backup operation using the provided options.
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 & setParallelWorkers(std::uint32_t value)
Sets the requested number of parallel workers.
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.
ServiceManager(Client &client, const ServiceManagerOptions &options={})
Attaches to the service manager specified by the given options.
std::function< void(std::string_view line)> VerboseOutput
Function invoked when a verbose service output line is available.