From: Libor Peltan Date: Fri, 9 Oct 2020 15:38:50 +0000 (+0200) Subject: backup: create dir path when restoring zonefile X-Git-Tag: v3.1.0~357^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ca60b170ddee763011f4abbd679a951b2e3890f;p=thirdparty%2Fknot-dns.git backup: create dir path when restoring zonefile --- diff --git a/src/knot/zone/backup.c b/src/knot/zone/backup.c index 3d203f9388..08b04a9797 100644 --- a/src/knot/zone/backup.c +++ b/src/knot/zone/backup.c @@ -252,7 +252,10 @@ int zone_backup(conf_t *conf, zone_t *zone) char *backup_zf = dir_file(ctx->backup_dir, local_zf); if (ctx->restore_mode) { - ret = copy_file(local_zf, backup_zf); + ret = make_path(local_zf, S_IRWXU | S_IRWXG); + if (ret == KNOT_EOK) { + ret = copy_file(local_zf, backup_zf); + } } else { conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name); bool can_flush = (conf_int(&val) > -1); diff --git a/tests-extra/tests/zone/backup/test.py b/tests-extra/tests/zone/backup/test.py index 0b90459816..f4a798eae7 100644 --- a/tests-extra/tests/zone/backup/test.py +++ b/tests-extra/tests/zone/backup/test.py @@ -69,6 +69,7 @@ if dnskey1_2 == dnskey1_1 or dnskey2_2 == dnskey2_1: test_added(master, zones, [ "NXDOMAIN", "NXDOMAIN" ]) +shutil.rmtree(master.dir + "/master") master.ctl("zone-restore +backupdir %s %s" % (backup_dir, zones[0].name), wait=True) t.sleep(5) @@ -81,6 +82,7 @@ if dnskey2_3 == dnskey2_1: test_added(master, zones, [ "NOERROR", "NXDOMAIN" ]) +master.ctl("zone-restore +backupdir %s %s" % (backup_dir, zones[1].name), wait=True) master.stop() keydir = master.keydir # BEWARE this is function invocation shutil.rmtree(keydir)