Skip to content

Commit

Permalink
TOPIC: enable ydb tools dump (local backup) (#14053)
Browse files Browse the repository at this point in the history
  • Loading branch information
jepett0 authored Jan 31, 2025
1 parent 93ccaa9 commit d0ca0e1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
16 changes: 16 additions & 0 deletions ydb/library/backup/backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/library/backup/db_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class TDbIterator {
return GetCurrentNode()->Type == NScheme::ESchemeEntryType::View;
}

bool IsTopic() const {
return GetCurrentNode()->Type == NScheme::ESchemeEntryType::Topic;
}

bool IsDir() const {
return GetCurrentNode()->Type == NScheme::ESchemeEntryType::Directory;
}
Expand Down
11 changes: 9 additions & 2 deletions ydb/public/sdk/cpp/src/client/topic/impl/topic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d0ca0e1

Please sign in to comment.