2022-04-19 18:15:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Backups/BackupInfo.h>
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class ASTBackupQuery;
|
|
|
|
|
|
|
|
/// Settings specified in the "SETTINGS" clause of a BACKUP query.
|
|
|
|
struct BackupSettings
|
|
|
|
{
|
2022-07-22 16:01:24 +00:00
|
|
|
/// ID of the backup operation, to identify it in the system.backups table. Auto-generated if not set.
|
|
|
|
String id;
|
|
|
|
|
2022-05-07 15:14:43 +00:00
|
|
|
/// Base backup, if it's set an incremental backup will be built. That means only differences made after the base backup will be put
|
|
|
|
/// into a new backup.
|
2022-04-19 18:15:27 +00:00
|
|
|
std::optional<BackupInfo> base_backup_info;
|
|
|
|
|
|
|
|
/// Compression method and level for writing the backup (when applicable).
|
|
|
|
String compression_method; /// "" means default method
|
|
|
|
int compression_level = -1; /// -1 means default level
|
|
|
|
|
|
|
|
/// Password used to encrypt the backup.
|
|
|
|
String password;
|
|
|
|
|
2023-07-14 17:35:31 +00:00
|
|
|
/// S3 storage class.
|
|
|
|
String s3_storage_class = "";
|
|
|
|
|
2022-04-19 18:15:27 +00:00
|
|
|
/// If this is set to true then only create queries will be written to backup,
|
|
|
|
/// without the data of tables.
|
|
|
|
bool structure_only = false;
|
|
|
|
|
2022-04-26 16:33:19 +00:00
|
|
|
/// Whether the BACKUP command must return immediately without waiting until the backup has completed.
|
|
|
|
bool async = false;
|
2022-04-19 18:15:27 +00:00
|
|
|
|
2023-05-03 23:27:16 +00:00
|
|
|
/// Whether the BACKUP command should decrypt files stored on encrypted disks.
|
|
|
|
bool decrypt_files_from_encrypted_disks = false;
|
|
|
|
|
2022-12-05 12:29:31 +00:00
|
|
|
/// Whether the BACKUP will omit similar files (within one backup only).
|
|
|
|
bool deduplicate_files = true;
|
|
|
|
|
2023-06-26 19:25:43 +00:00
|
|
|
/// Whether native copy is allowed (optimization for cloud storages, that sometimes could have bugs)
|
2023-06-28 15:16:02 +00:00
|
|
|
bool allow_s3_native_copy = true;
|
2023-06-26 19:25:43 +00:00
|
|
|
|
2023-07-20 07:46:22 +00:00
|
|
|
/// Allow to use the filesystem cache in passive mode - benefit from the existing cache entries,
|
|
|
|
/// but don't put more entries into the cache.
|
2023-07-23 11:00:17 +00:00
|
|
|
bool read_from_filesystem_cache = true;
|
2023-07-20 07:46:22 +00:00
|
|
|
|
2022-04-19 18:15:27 +00:00
|
|
|
/// 1-based shard index to store in the backup. 0 means all shards.
|
|
|
|
/// Can only be used with BACKUP ON CLUSTER.
|
2022-04-25 10:54:13 +00:00
|
|
|
size_t shard_num = 0;
|
2022-04-19 18:15:27 +00:00
|
|
|
|
|
|
|
/// 1-based replica index to store in the backup. 0 means all replicas (see also allow_storing_multiple_replicas).
|
|
|
|
/// Can only be used with BACKUP ON CLUSTER.
|
2022-04-25 10:54:13 +00:00
|
|
|
size_t replica_num = 0;
|
2022-04-19 18:15:27 +00:00
|
|
|
|
|
|
|
/// Internal, should not be specified by user.
|
|
|
|
/// Whether this backup is a part of a distributed backup created by BACKUP ON CLUSTER.
|
|
|
|
bool internal = false;
|
|
|
|
|
2022-05-01 13:36:32 +00:00
|
|
|
/// Internal, should not be specified by user.
|
|
|
|
/// The current host's ID in the format 'escaped_host_name:port'.
|
|
|
|
String host_id;
|
|
|
|
|
|
|
|
/// Internal, should not be specified by user.
|
|
|
|
/// Cluster's hosts' IDs in the format 'escaped_host_name:port' for all shards and replicas in a cluster specified in BACKUP ON CLUSTER.
|
|
|
|
std::vector<Strings> cluster_host_ids;
|
|
|
|
|
2022-07-15 07:42:56 +00:00
|
|
|
/// Internal, should not be specified by user.
|
|
|
|
/// UUID of the backup. If it's not set it will be generated randomly.
|
|
|
|
std::optional<UUID> backup_uuid;
|
|
|
|
|
2022-04-19 18:15:27 +00:00
|
|
|
static BackupSettings fromBackupQuery(const ASTBackupQuery & query);
|
2022-04-29 10:14:53 +00:00
|
|
|
void copySettingsToQuery(ASTBackupQuery & query) const;
|
2022-05-01 13:36:32 +00:00
|
|
|
|
|
|
|
struct Util
|
|
|
|
{
|
|
|
|
static std::vector<Strings> clusterHostIDsFromAST(const IAST & ast);
|
|
|
|
static ASTPtr clusterHostIDsToAST(const std::vector<Strings> & cluster_host_ids);
|
|
|
|
static std::pair<size_t, size_t> findShardNumAndReplicaNum(const std::vector<Strings> & cluster_host_ids, const String & host_id);
|
2022-04-30 09:46:42 +00:00
|
|
|
static Strings filterHostIDs(const std::vector<Strings> & cluster_host_ids, size_t only_shard_num, size_t only_replica_num);
|
2022-05-01 13:36:32 +00:00
|
|
|
};
|
2022-04-19 18:15:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|