Skip to content
Snippets Groups Projects
Commit fa143c2c authored by David Vasek's avatar David Vasek
Browse files

zone backup: add new filters (detailed selection of backup components)

The filters are now called "filters" in zone-backup/zone-restore, not "flags" as recently.
parent b90bab29
No related branches found
No related tags found
1 merge request!1293add new filters to "zone-backup"/"zone-restore" that allow detailed selection of backup/restore components
......@@ -130,15 +130,22 @@ Trigger a zone journal flush to the configured zone file. If an output
directory is specified, the current zone is immediately dumped (in the
blocking mode) to a zone file in the specified directory. (#)
.TP
\fBzone\-backup\fP [\fIzone\fP\&...] \fB+backupdir\fP \fIdirectory\fP [\fB+journal\fP] [\fB+nozonefile\fP]
Trigger a zone data and metadata backup to specified directory.
Optional flag \fB+journal\fP backs up also zone journal, whereas \fB+nozonefile\fP
avoids backing up current zone contents to a zone file. If zone flushing is disabled,
original zone file is backed up instead. (#)
.TP
\fBzone\-restore\fP [\fIzone\fP\&...] \fB+backupdir\fP \fIdirectory\fP [\fB+journal\fP] [\fB+nozonefile\fP]
Trigger a zone data and metadata restore from specified backup directory.
Optional flags are equivalent to \fBzone\-backup\fP\&. (#)
\fBzone\-backup\fP [\fIzone\fP\&...] \fB+backupdir\fP \fIdirectory\fP [\fIfilter\fP\&...]
Trigger a zone data and metadata backup to a specified directory.
Available filters are \fB+journal\fP, \fB+timers\fP, \fB+kaspdb\fP, \fB+catalog\fP,
\fB+zonefile\fP, and their negative counterparts \fB+nojournal\fP, \fB+notimers\fP,
\fB+nokaspdb\fP, \fB+nocatalog\fP, and \fB+nozonefile\fP\&. With these filters set,
zone\(aqs journal, zone related timers, zone related data in the KASP database,
zone\(aqs catalog, and the zone contents, respectively, are backed up,
or omitted from the backup. By default, filters \fB+timers\fP, \fB+kaspdb\fP,
\fB+catalog\fP, \fB+zonefile\fP, and \fB+nojournal\fP are set. Setting a filter
for an item doesn\(aqt change default settings for other items. If zone flushing
is disabled, original zone file is backed up instead of writing out zone
contents to a file. (#)
.TP
\fBzone\-restore\fP [\fIzone\fP\&...] \fB+backupdir\fP \fIdirectory\fP [\fIfilter\fP\&...]
Trigger a zone data and metadata restore from a specified backup directory.
Optional filters are equivalent to the same filters of \fBzone\-backup\fP\&. (#)
.TP
\fBzone\-sign\fP [\fIzone\fP\&...]
Trigger a DNSSEC re\-sign of the zone. Existing signatures will be dropped.
......
......@@ -107,15 +107,22 @@ Actions
directory is specified, the current zone is immediately dumped (in the
blocking mode) to a zone file in the specified directory. (#)
**zone-backup** [*zone*...] **+backupdir** *directory* [**+journal**] [**+nozonefile**]
Trigger a zone data and metadata backup to specified directory.
Optional flag **+journal** backs up also zone journal, whereas **+nozonefile**
avoids backing up current zone contents to a zone file. If zone flushing is disabled,
original zone file is backed up instead. (#)
**zone-restore** [*zone*...] **+backupdir** *directory* [**+journal**] [**+nozonefile**]
Trigger a zone data and metadata restore from specified backup directory.
Optional flags are equivalent to **zone-backup**. (#)
**zone-backup** [*zone*...] **+backupdir** *directory* [*filter*...]
Trigger a zone data and metadata backup to a specified directory.
Available filters are **+journal**, **+timers**, **+kaspdb**, **+catalog**,
**+zonefile**, and their negative counterparts **+nojournal**, **+notimers**,
**+nokaspdb**, **+nocatalog**, and **+nozonefile**. With these filters set,
zone's journal, zone related timers, zone related data in the KASP database,
zone's catalog, and the zone contents, respectively, are backed up,
or omitted from the backup. By default, filters **+timers**, **+kaspdb**,
**+catalog**, **+zonefile**, and **+nojournal** are set. Setting a filter
for an item doesn't change default settings for other items. If zone flushing
is disabled, original zone file is backed up instead of writing out zone
contents to a file. (#)
**zone-restore** [*zone*...] **+backupdir** *directory* [*filter*...]
Trigger a zone data and metadata restore from a specified backup directory.
Optional filters are equivalent to the same filters of **zone-backup**. (#)
**zone-sign** [*zone*...]
Trigger a DNSSEC re-sign of the zone. Existing signatures will be dropped.
......
......@@ -342,19 +342,21 @@ int zone_backup(conf_t *conf, zone_t *zone)
}
}
knot_lmdb_db_t *kasp_from = zone->kaspdb, *kasp_to = &ctx->bck_kasp_db;
BACKUP_SWAP(ctx, kasp_from, kasp_to);
if (knot_lmdb_exists(kasp_from)) {
ret = kasp_db_backup(zone->name, kasp_from, kasp_to);
if (ret != KNOT_EOK) {
LOG_FAIL("KASP database");
goto done;
}
if (ctx->backup_kaspdb) {
knot_lmdb_db_t *kasp_from = zone->kaspdb, *kasp_to = &ctx->bck_kasp_db;
BACKUP_SWAP(ctx, kasp_from, kasp_to);
if (knot_lmdb_exists(kasp_from)) {
ret = kasp_db_backup(zone->name, kasp_from, kasp_to);
if (ret != KNOT_EOK) {
LOG_FAIL("KASP database");
goto done;
}
ret = backup_keystore(conf, zone, ctx);
if (ret != KNOT_EOK) {
goto done;
ret = backup_keystore(conf, zone, ctx);
if (ret != KNOT_EOK) {
goto done;
}
}
}
......@@ -371,19 +373,21 @@ int zone_backup(conf_t *conf, zone_t *zone)
goto done;
}
ret = knot_lmdb_open(&ctx->bck_timer_db);
if (ret != KNOT_EOK) {
LOG_FAIL("timers open");
goto done;
}
if (ctx->restore_mode) {
ret = zone_timers_read(&ctx->bck_timer_db, zone->name, &zone->timers);
zone_timers_sanitize(conf, zone);
} else {
ret = zone_timers_write(&ctx->bck_timer_db, zone->name, &zone->timers);
}
if (ret != KNOT_EOK) {
LOG_FAIL("timers");
if (ctx->backup_timers) {
ret = knot_lmdb_open(&ctx->bck_timer_db);
if (ret != KNOT_EOK) {
LOG_FAIL("timers open");
goto done;
}
if (ctx->restore_mode) {
ret = zone_timers_read(&ctx->bck_timer_db, zone->name, &zone->timers);
zone_timers_sanitize(conf, zone);
} else {
ret = zone_timers_write(&ctx->bck_timer_db, zone->name, &zone->timers);
}
if (ret != KNOT_EOK) {
LOG_FAIL("timers");
}
}
done:
......@@ -395,6 +399,10 @@ done:
int global_backup(zone_backup_ctx_t *ctx, catalog_t *catalog,
const knot_dname_t *zone_only)
{
if (!ctx->backup_catalog) {
return KNOT_EOK;
}
knot_lmdb_db_t *cat_from = &catalog->db, *cat_to = &ctx->bck_catalog;
BACKUP_SWAP(ctx, cat_from, cat_to);
return catalog_copy(cat_from, cat_to, zone_only, !ctx->restore_mode);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment