Solved Deleted zone file by accident, can it be rebuild?

Richard G

Verified User
Joined
Jul 6, 2008
Messages
14,307
Location
Maastricht
I deleted a zone file by accident. Is there anyway it can be rebuild, evt. using the DA default values?
 
Maybe nice to know for the future.

It was a hobby domain so I just copied everything from another hobby domain, changed the domain name and content and used the rewrite command.

But it would be nice to know how it really should be done "the correct way", would this happen in the future sometime again.
 
Hello.
That won't help, because in the named.conf file there will only be a link to the domain.nl.db zone file, which was deleted.
There is no way to rebuild anything from only the named.conf file.
 
WelI, I was explain it wrong. First you create a new zone for the domain that is missing and check if there is to /etc/named.conf.

Regards,
GB
 
Yes thank you, that is what I did now already.
so I just copied everything from another hobby domain, changed the domain name and content and used the rewrite command.
I don't have the issue anymore at this moment.

But as far as I remember there was some official way (console command or script) in DA to re-create or rebuild zone files from the default template. That is the one I'm looking for if something like this would be happening in the future.
 
Thank you.
I had found that one already. But it's 12 years old. That is the rewrite command I used for 1 user. But the database file must exist then already (which I copied from another one) but that is not rebuilding like the script does.

The script which pointed to is this script:
but that is to rebuild -all- zonefiles.

I would like to know if there is such script for 1 user. Like also @ditto asked in 2019 in that thread. But never got answered.
So the question is still open....
 
Well, I see it very simple, replace `ls ${DA_USERS_DIR}` with "username_to_fix" or replace `ls ${DA_USERS_DIR}` with $1 and call the script like
./fix_db.sh username. :)


Regards,
GB
 
Last edited:
Not that simple I think, because in the code I see:
Code:
for DOMAIN in `cat ${DA_USERS_DIR}/${DA_USER}/domains.list
What you say would get me
Code:
for DOMAIN in `cat ${username_to_fix}/${DA_USER}/domains.list
or
Code:
for DOMAIN in `cat $!/${DA_USER}/domains.list
seems not correct to me, this way you would get the user twice right? But the first one needs to be the users dir.
Which to me is the /usr/local/directadmin/data/users dir, not the username, that comes after that. Needs more fixing.

I hope they create an easier way for this. And I don't know any scripting so is hard anyway. ;)
 
Hi,

The first and based loop is going on the first line << for DA_USER in `ls ${DA_USERS_DIR}`; do >> DA_USER is the variable that the loop is going. did you tried?

Regards,
GB
 
No I didn't because I can't script and don't need it anymore right now.
I would just like a ready and working option from DA itself. ;)
I won't take the risk by adjusting that big a script myself and maybe making errors.
But thank you for helping.
 
maybe just execute like this in one line

Code:
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d400
 
and you don't have backups? For such cases I have separate backups called "template"
08-08-2023 07-28-43.jpg

but without such backup, I will copy/rename/correct nearest working zone-file as you did.
 
maybe just execute like this in one line
I did that now, but for that a zone file needs to exist. Also I doubt a single line would work if a complete script (see docs) is used for it.
I'm already glad I could fix it.

and you don't have backups? For such cases I have separate backups called "template"
The only backups I don't have is zone file backups. The screenshot you show is just website backup only. Website was fully present.

I was being a bit too fast last night. Next time I will make a /var/named backup before I'm going to move things. I had forgotten to disable the multi-server setup and then deleted the zone file on the server the domain had to be transferred to, which ofcourse caused the original zone file on the current server to be deleted to. :D
I was already glad I managed to fix it and it was just a hobby domain. I always first test with hobby domains.
 
The screenshot you show is just website backup only.
But regular DA backup has DNS zone backuped too by default, you can't disable it. I just use simplified separate backup task to keep only DA-account configs (data/mysql backuped separetelly too)
 
Back
Top