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

backup: return KNOT_ENOTSUP when trying to restore from possible future backup format version

Returning KNOT_ENOTSUP makes more sense than returning KNOT_EMALF in such situations.
parent 2baf13a1
No related branches found
No related tags found
1 merge request!1325backup improvements -- modified backup format (BACKUP_FORMAT_2), label file, improved backup locking, etc.
......@@ -155,7 +155,9 @@ static int get_backup_format(zone_backup_ctx_t *ctx)
while (knot_getline(&line, &line_size, file) != -1) {
int value;
if (sscanf(line, LABEL_FILE_FORMAT, &value) != 0) {
if ((BACKUP_FORMAT_1 < value) && (value < BACKUP_FORMAT_TERM)) {
if (value >= BACKUP_FORMAT_TERM) {
ret = KNOT_ENOTSUP;
} else if (value > BACKUP_FORMAT_1) {
ctx->backup_format = value;
ret = KNOT_EOK;
}
......
label: Knot DNS Backup
backup_format: 1
identity: tester.knot-dns.cz
started_time: 2021-07-07 14:39:48 CEST
finished_time: 2021-07-07 14:39:48 CEST
knot_version: 3.1.dev.1625122029.e48145931
parameters: +zonefile +nojournal +timers +kaspdb +catalog +backupdir backup2
zone_count: 3
File added
File added
;; Zone dump (Knot DNS 3.1.dev.1625122029.e48145931)
example1. 10 SOA a.ns.example1. admin.example1. 1 10 10 120 10
example1. 10 NS a.ns.example1.
example1. 10 NS b.ns.example1.
example1. 10 NS ns.out.
deleg.example1. 10 NS a.ns.deleg.example1.
deleg.example1. 10 NS ns.out.
a.ns.deleg.example1. 10 A 10.0.1.1
a.ns.deleg.example1. 10 AAAA fd00::1:1
a.mail.example1. 10 A 10.0.1.1
b.mail.example1. 10 AAAA fd00::1:1
cname.mail.example1. 10 CNAME a.mail.example1.
mx.example1. 10 MX 10 a.mail.example1.
mx.example1. 10 MX 20 b.mail.example1.
mx.example1. 10 MX 30 mail.out.
mx-cname.example1. 10 MX 10 cname.mail.example1.
a.ns.example1. 10 A 10.0.0.1
a.ns.example1. 10 AAAA fd00::a1
b.ns.example1. 10 AAAA fd00::b1
b.ns.example1. 10 AAAA fd00::b2
ptr.example1. 10 PTR target.example1.
a.service.example1. 10 TXT "no address"
b.service.example1. 10 AAAA fd00::2:1
b.service.example1. 10 AAAA fd00::2:2
b.service.example1. 10 AAAA fd00::2:3
srv.example1. 10 SRV 10 0 1000 a.service.example1.
srv.example1. 10 SRV 10 0 1000 b.service.example1.
srv.example1. 10 SRV 10 0 1000 service.out.
target.example1. 10 A 10.0.3.1
target.example1. 10 AAAA fd00::3:1
;; Written 29 records
;; Time 2021-07-07 14:39:48 CEST
;; Zone dump (Knot DNS 3.1.dev.1625122029.e48145931)
example2. 3600 SOA dns1.example2. hostmaster.example2. 1 1 1 10 600
example2. 3600 NS dns1.example2.
dns1.example2. 3600 A 192.0.2.1
;; Written 3 records
;; Time 2021-07-07 14:39:48 CEST
;; Zone dump (Knot DNS 3.1.dev.1625122029.e48145931)
example3. 3600 SOA dns1.example3. hostmaster.example3. 2010111213 10800 3600 1209600 7200
example3. 3600 NS dns1.example3.
example3. 3600 NS dns2.example3.
added.example3. 3600 A 1.2.3.4
dns1.example3. 3600 A 192.0.2.1
dns1.example3. 3600 AAAA 2001:db8::1
dns2.example3. 3600 A 192.0.2.2
dns2.example3. 3600 AAAA 2001:db8::2
;; Written 8 records
;; Time 2021-07-07 14:39:48 CEST
......@@ -31,7 +31,7 @@ zones2 = t.zone("example1.", file_name="example1.file", storage=".") \
+ t.zone("example2.", file_name="example2.file", storage=".") \
+ t.zone("example3.", file_name="example3.file", storage=".")
t.link(zones2, master2)
for i in range(2, 7):
for i in range(2, 8):
dir_from = os.path.join(t.data_dir, "backup%d" % i)
dir_to = os.path.join(master2.dir, "backup%d" % i)
shutil.copytree(dir_from, dir_to)
......@@ -151,11 +151,18 @@ try:
except:
pass
# Attempt to restore from unsupported backup format number, expected (malformed data).
# Attempt to restore from unsupported backup format number, expected (operation not supported).
try:
master2.ctl("-f zone-restore +backupdir %s" % backup6_dir, wait=True)
set_err("RESTORE FROM UNSUPPORTED BACKUP FORMAT VERSION ALLOWED")
except:
pass
# Attempt to restore from non-existant backup format number, expected (malformed data).
try:
master2.ctl("-f zone-restore +backupdir %s" % backup7_dir, wait=True)
set_err("RESTORE FROM NON-EXISTANT BACKUP FORMAT VERSION ALLOWED")
except:
pass
t.stop()
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