2021-08-18 22:19:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-11-05 14:18:23 +00:00
|
|
|
#include <Backups/IBackup.h>
|
|
|
|
#include <Backups/BackupInfo.h>
|
2021-08-18 22:19:14 +00:00
|
|
|
#include <Core/Types.h>
|
2023-07-20 07:46:22 +00:00
|
|
|
#include <IO/ReadSettings.h>
|
|
|
|
#include <IO/WriteSettings.h>
|
2021-11-05 14:18:23 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
2021-08-18 22:19:14 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
#include <memory>
|
2021-11-05 14:18:23 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <unordered_map>
|
2021-08-18 22:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2022-05-08 21:41:49 +00:00
|
|
|
class IBackupCoordination;
|
2021-08-18 22:19:14 +00:00
|
|
|
class Context;
|
2021-11-05 14:18:23 +00:00
|
|
|
using ContextPtr = std::shared_ptr<const Context>;
|
2021-08-18 22:19:14 +00:00
|
|
|
|
|
|
|
/// Factory for implementations of the IBackup interface.
|
|
|
|
class BackupFactory : boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
2021-11-05 14:18:23 +00:00
|
|
|
using OpenMode = IBackup::OpenMode;
|
2021-08-18 22:19:14 +00:00
|
|
|
|
2021-11-05 14:18:23 +00:00
|
|
|
struct CreateParams
|
|
|
|
{
|
|
|
|
OpenMode open_mode = OpenMode::WRITE;
|
|
|
|
BackupInfo backup_info;
|
|
|
|
std::optional<BackupInfo> base_backup_info;
|
2022-01-28 17:33:35 +00:00
|
|
|
String compression_method;
|
|
|
|
int compression_level = -1;
|
|
|
|
String password;
|
2023-07-14 17:35:31 +00:00
|
|
|
String s3_storage_class;
|
2021-11-05 14:18:23 +00:00
|
|
|
ContextPtr context;
|
2022-04-19 18:15:27 +00:00
|
|
|
bool is_internal_backup = false;
|
2022-05-08 21:41:49 +00:00
|
|
|
std::shared_ptr<IBackupCoordination> backup_coordination;
|
2022-07-15 07:42:56 +00:00
|
|
|
std::optional<UUID> backup_uuid;
|
2022-12-05 12:29:31 +00:00
|
|
|
bool deduplicate_files = true;
|
2023-06-28 15:16:02 +00:00
|
|
|
bool allow_s3_native_copy = true;
|
2023-08-11 08:31:08 +00:00
|
|
|
bool use_same_s3_credentials_for_base_backup = false;
|
2023-07-20 07:46:22 +00:00
|
|
|
ReadSettings read_settings;
|
|
|
|
WriteSettings write_settings;
|
2021-11-05 14:18:23 +00:00
|
|
|
};
|
2021-08-18 22:19:14 +00:00
|
|
|
|
2021-11-05 14:18:23 +00:00
|
|
|
static BackupFactory & instance();
|
2021-08-18 22:19:14 +00:00
|
|
|
|
2021-11-05 14:18:23 +00:00
|
|
|
/// Creates a new backup or opens it.
|
|
|
|
BackupMutablePtr createBackup(const CreateParams & params) const;
|
|
|
|
|
|
|
|
using CreatorFn = std::function<BackupMutablePtr(const CreateParams & params)>;
|
|
|
|
void registerBackupEngine(const String & engine_name, const CreatorFn & creator_fn);
|
2021-08-18 22:19:14 +00:00
|
|
|
|
|
|
|
private:
|
2021-11-05 14:18:23 +00:00
|
|
|
BackupFactory();
|
|
|
|
|
|
|
|
std::unordered_map<String, CreatorFn> creators;
|
2021-08-18 22:19:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|