diff options
author | Daniil Demin <deminds@ydb.tech> | 2025-01-31 20:49:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-31 17:49:40 +0000 |
commit | d0ca0e1241f56592296404ca38b5405af0ac9159 (patch) | |
tree | 9125c0107236489f3d25e91582404ee8170cffc1 | |
parent | 93ccaa946b8e678598797dff179c5c7e3623d2e5 (diff) | |
download | ydb-d0ca0e1241f56592296404ca38b5405af0ac9159.tar.gz |
TOPIC: enable ydb tools dump (local backup) (#14053)
-rw-r--r-- | ydb/library/backup/backup.cpp | 16 | ||||
-rw-r--r-- | ydb/library/backup/db_iterator.h | 4 | ||||
-rw-r--r-- | ydb/public/sdk/cpp/src/client/topic/impl/topic.cpp | 11 |
3 files changed, 29 insertions, 2 deletions
diff --git a/ydb/library/backup/backup.cpp b/ydb/library/backup/backup.cpp index 762a65a3af7..5d11a3b7815 100644 --- a/ydb/library/backup/backup.cpp +++ b/ydb/library/backup/backup.cpp @@ -596,6 +596,19 @@ void BackupView(TDriver driver, const TString& dbBackupRoot, const TString& dbPa BackupPermissions(driver, dbPath, fsBackupFolder); } +void BackupTopic(TDriver driver, const TString& dbPath, const TFsPath& fsBackupFolder) { + Y_ENSURE(!dbPath.empty()); + LOG_I("Backup topic " << dbPath.Quote() << " to " << fsBackupFolder.GetPath().Quote()); + + const auto topicDescription = DescribeTopic(driver, dbPath); + + Ydb::Topic::CreateTopicRequest creationRequest; + topicDescription.SerializeTo(creationRequest); + + WriteProtoToFile(creationRequest, fsBackupFolder, NDump::NFiles::CreateTopic()); + BackupPermissions(driver, dbPath, fsBackupFolder); +} + void CreateClusterDirectory(const TDriver& driver, const TString& path, bool rootBackupDir = false) { if (rootBackupDir) { LOG_I("Create temporary directory " << path.Quote()); @@ -683,6 +696,9 @@ void BackupFolderImpl(TDriver driver, const TString& dbPrefix, const TString& ba if (dbIt.IsView()) { BackupView(driver, dbIt.GetTraverseRoot(), dbIt.GetRelPath(), childFolderPath, issues); } + if (dbIt.IsTopic()) { + BackupTopic(driver, dbIt.GetFullPath(), childFolderPath); + } dbIt.Next(); } } diff --git a/ydb/library/backup/db_iterator.h b/ydb/library/backup/db_iterator.h index 6b94f68919a..35fe95be71b 100644 --- a/ydb/library/backup/db_iterator.h +++ b/ydb/library/backup/db_iterator.h @@ -133,6 +133,10 @@ public: return GetCurrentNode()->Type == NScheme::ESchemeEntryType::View; } + bool IsTopic() const { + return GetCurrentNode()->Type == NScheme::ESchemeEntryType::Topic; + } + bool IsDir() const { return GetCurrentNode()->Type == NScheme::ESchemeEntryType::Directory; } diff --git a/ydb/public/sdk/cpp/src/client/topic/impl/topic.cpp b/ydb/public/sdk/cpp/src/client/topic/impl/topic.cpp index ea3d0b59ee6..6944e60eb11 100644 --- a/ydb/public/sdk/cpp/src/client/topic/impl/topic.cpp +++ b/ydb/public/sdk/cpp/src/client/topic/impl/topic.cpp @@ -184,8 +184,15 @@ const std::vector<TConsumer>& TTopicDescription::GetConsumers() const { } void TTopicDescription::SerializeTo(Ydb::Topic::CreateTopicRequest& request) const { - Y_UNUSED(request); - Y_ABORT("Not implemented"); + *request.mutable_partitioning_settings() = Proto_.partitioning_settings(); + *request.mutable_retention_period() = Proto_.retention_period(); + request.set_retention_storage_mb(Proto_.retention_storage_mb()); + *request.mutable_supported_codecs() = Proto_.supported_codecs(); + request.set_partition_write_speed_bytes_per_second(Proto_.partition_write_speed_bytes_per_second()); + request.set_partition_write_burst_bytes(Proto_.partition_write_burst_bytes()); + *request.mutable_attributes() = Proto_.attributes(); + *request.mutable_consumers() = Proto_.consumers(); + request.set_metering_mode(Proto_.metering_mode()); } const Ydb::Topic::DescribeTopicResult& TTopicDescription::GetProto() const { |