Bug fixes in fdbbackup modify command. Active snapshot interval was wrong. New backup destination containers were not being created. Renamed some variables for clarity.

This commit is contained in:
Stephen Atherton 2019-03-05 18:05:52 -08:00
parent a5b53d3c0f
commit a57ddd29f2
2 changed files with 31 additions and 11 deletions

View File

@ -197,7 +197,7 @@ The following options apply to most subcommands:
Path to the cluster file that should be used to connect to the FoundationDB cluster you want to use. If not specified, a :ref:`default cluster file <default-cluster-file>` will be used.
``-d <BACKUP_URL>``
The Backup URL which the subcommand should read, write, or modify. For ``start`` operations, the Backup URL must be accessible by the ``backup_agent`` processes.
The Backup URL which the subcommand should read, write, or modify. For ``start`` and ``modify`` operations, the Backup URL must be accessible by the ``backup_agent`` processes.
``-t <TAG>``
A "tag" is a named slot in which a backup task executes. Backups on different named tags make progress and are controlled independently, though their executions are handled by the same set of backup agent processes. Any number of unique backup tags can be active at once. It the tag is not specified, the default tag name "default" is used.

View File

@ -2082,14 +2082,35 @@ ACTOR Future<Void> listBackup(std::string baseUrl) {
struct BackupModifyOptions {
Optional<std::string> verifyUID;
Optional<std::string> destURL;
Optional<int> snapshotInterval;
Optional<int> activeSnapshotInterval;
Optional<int> snapshotIntervalSeconds;
Optional<int> activeSnapshotIntervalSeconds;
bool hasChanges() const {
return destURL.present() || snapshotIntervalSeconds.present() || activeSnapshotIntervalSeconds.present();
}
};
ACTOR Future<Void> modifyBackup(Database db, std::string tagName, BackupModifyOptions options) {
if(!options.hasChanges()) {
fprintf(stderr, "No changes were specified, nothing to do!\n");
throw backup_error();
}
state KeyBackedTag tag = makeBackupTag(tagName);
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction());
state Reference<IBackupContainer> bc;
if(options.destURL.present()) {
bc = openBackupContainer(exeBackup.toString().c_str(), options.destURL.get());
try {
Void _ = wait(timeoutError(bc->create(), 30));
} catch(Error &e) {
if(e.code() == error_code_actor_cancelled)
throw;
fprintf(stderr, "ERROR: Could not create backup container at '%s': %s\n", options.destURL.get().c_str(), e.what());
throw backup_error();
}
}
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(db));
loop {
try {
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
@ -2113,17 +2134,16 @@ ACTOR Future<Void> modifyBackup(Database db, std::string tagName, BackupModifyOp
throw backup_error();
}
if(options.snapshotInterval.present()) {
config.snapshotIntervalSeconds().set(tr, options.snapshotInterval.get());
if(options.snapshotIntervalSeconds.present()) {
config.snapshotIntervalSeconds().set(tr, options.snapshotIntervalSeconds.get());
}
if(options.activeSnapshotInterval.present()) {
if(options.activeSnapshotIntervalSeconds.present()) {
Version begin = wait(config.snapshotBeginVersion().getOrThrow(tr, false, backup_error()));
config.snapshotTargetEndVersion().set(tr, begin);
config.snapshotTargetEndVersion().set(tr, begin + ((int64_t)options.activeSnapshotIntervalSeconds.get() * CLIENT_KNOBS->CORE_VERSIONSPERSECOND));
}
if(options.destURL.present()) {
Reference<IBackupContainer> bc = openBackupContainer(exeBackup.toString().c_str(), options.destURL.get());
config.backupContainer().set(tr, bc);
}
@ -2720,10 +2740,10 @@ int main(int argc, char* argv[]) {
}
if(optId == OPT_SNAPSHOTINTERVAL) {
snapshotIntervalSeconds = seconds;
modifyOptions.snapshotInterval = seconds;
modifyOptions.snapshotIntervalSeconds = seconds;
}
else if(optId == OPT_MOD_ACTIVE_INTERVAL) {
modifyOptions.activeSnapshotInterval = seconds;
modifyOptions.activeSnapshotIntervalSeconds = seconds;
}
break;
}