TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
4.25k stars 418 forks source link

Difficulty to migrate to another system #959

Closed EHRETic closed 2 months ago

EHRETic commented 2 months ago

Hello there

I'm struggling a little bit migrating from a Linux to another one freshly installed with latest Almalinux. Thing is backup/restore functionality is probably not working because I have more than 40Go of queries in SQLite . So tried to rsync folders between the 2 hosts.

My source server is qui an old instance and I noticed the folder structure is completely different and I tried 2 things (service was cut on both) /etc/dns/ to /etc/dns /et/dns/config to /etc/dns (I noticed folder structure was the same in config folder)

Old /etc/dns folder structure:

image

New folder structure: image

But none of these transfers worked, I had no previous password, no config nor data after transfer.

How can I perform the transfert? Thx in advance ๐Ÿ˜‰

ShreyasZare commented 2 months ago

Thanks for the post.

Thing is backup/restore functionality is probably not working because I have more than 40Go of queries in SQLite .

Did you see any errors when trying to restore using the backup zip file? If there is any error log in the DNS logs then do post it here so that the issue can be understood better and can be fixed.

In any case you can manually restore the backup to your new installation by copying file like you tried. As you noticed, the paths have been changed slightly few versions ago. Earlier, both the app files and the config files were together in /etc/dns/ and /etc/dns/config folders respectively. With new setup, the app files are in /opt/technitium/dns and the config files are in /etc/dns/ folder.

So, to manually restore the backup, you first need to stop the DNS server on the new server using systemctl stop dns. Copy the zip file on the server and extract it overwriting all files into /etc/dns/ folder. Once the zip is extracted, start the DNS server using systemctl start dns. This will complete the restore process and you should see the restored data when you login.

If you do not know the old password, you can just follow the reset password steps that are given on the login page.

EHRETic commented 2 months ago

Did you see any errors when trying to restore using the backup zip file? If there is any error log in the DNS logs then do post it here so that the issue can be understood better and can be fixed.

Yes, I got this (I did open the port on my server because for daily use, I use Technitium behind NGINX for SSL management)

{"status":"error","errorMessage":"Could not find file \u0027/etc/dns/config/apps/Query Logs (Sqlite)/querylogs.db-journal\u0027.","stackTrace":" at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)\n at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64\u0026 fileLength, UnixFileMode\u0026 filePermissions, Boolean failForSymlink, Boolean\u0026 wasSymlink, Func\u00604 createOpenException)\n at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable\u00601 unixCreateMode)\n at DnsServerCore.WebServiceSettingsApi.CreateBackupEntryFromFileAsync(ZipArchive backupZip, String sourceFileName, String entryName) in Z:\\Technitium\\Projects\\DnsServer\\DnsServerCore\\WebServiceSettingsApi.cs:line 207\n at DnsServerCore.WebServiceSettingsApi.BackupSettingsAsync(HttpContext context) in Z:\\Technitium\\Projects\\DnsServer\\DnsServerCore\\WebServiceSettingsApi.cs:line 1604\n at DnsServerCore.DnsWebService.WebServiceApiMiddleware(HttpContext context, RequestDelegate next) in Z:\\Technitium\\Projects\\DnsServer\\DnsServerCore\\DnsWebService.cs:line 625\n at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.\u003CInvoke\u003Eg__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)"}

I already know that with the backup file I should be able to do whatever I want, I just completed 2 migrations (with rsync only, not with the backup file)

But those migrations were from newer versions so it worked like a charm. I'm juste struggling with my very first instance ๐Ÿ˜‡

ShreyasZare commented 2 months ago

Thanks for the error log. It looks like one file which existed when backup started got removed due to some reasons causing this error. Retrying to take another backup should work.

EHRETic commented 2 months ago

It indeed did work afterwards!

I'm trying an hybrid approach : I used the backup file for all main settings and for all the big data (stats, logs and SQLite, I use rsync because even if I could download the zip files, it's really difficult to manage them. Main config restore worked already, so I'm confident.

I'll let you know ๐Ÿ˜‰

EHRETic commented 2 months ago

Mmmhhh, worked except for log files, despite they are there in the folder.

Is there any kind of registering system for those files or does log format differ?

ShreyasZare commented 2 months ago

Mmmhhh, worked except for log files, despite they are there in the folder.

Do you see any error in the DNS logs?

Is there any kind of registering system for those files or does log format differ?

Logs are just text files. The backup process is essentially just creating a zip file for the selected items. Its equivalent to just manually zip the config folder's contents.

The restore process to is just zip file extraction with only difference that after extraction, the config files are reloaded without need for restarting the DNS server. This can be done manually too but requires the DNS server to be shutdown before changing the config files just to ensure that it does not overwrite the restored files with old in-memory data.

EHRETic commented 2 months ago

Nope, no error, here is what I see :

Capture dโ€™eฬcran 2024-07-05 aฬ€ 16 07 14

But in folder:

Capture dโ€™eฬcran 2024-07-05 aฬ€ 16 07 42

Worst case, I remove them all because normally, it is a duplicate of SQLite logs no?

EHRETic commented 2 months ago

This is last starting logs (obfuscated):

[2024-07-05 16:06:29 Local] DHCP Server successfully unloaded scope: Default
[2024-07-05 16:06:29 Local] DNS Server (v12.2.1.0) was stopped successfully.
[2024-07-05 16:06:29 Local] DNS Server auth config file was saved: /etc/dns/auth.config
[2024-07-05 16:06:29 Local] Logging stopped.
[2024-07-05 16:06:29 Local] Logging started.
[2024-07-05 16:06:30 Local] DNS Server auth config file was loaded: /etc/dns/auth.config
[2024-07-05 16:06:30 Local] DNS Server config file was loaded: /etc/dns/dns.config
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.in-addr.arpa.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.in-addr.arpa.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.in-addr.arpa.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.in-addr.arpa.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.in-addr.arpa.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.in-addr.arpa.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.local.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.sec.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/x.test.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/google.com.zone
[2024-07-05 16:06:30 Local] DNS Server successfully loaded zone file: /etc/dns/zones/ntp.org.zone
[2024-07-05 16:06:30 Local] DNS Server is loading allowed zone file: /etc/dns/allowed.config
[2024-07-05 16:06:30 Local] DNS Server allowed zone file was loaded: /etc/dns/allowed.config
[2024-07-05 16:06:30 Local] DNS Server is loading blocked zone file: /etc/dns/blocked.config
[2024-07-05 16:06:30 Local] DNS Server blocked zone file was loaded: /etc/dns/blocked.config
[2024-07-05 16:06:30 Local] DNS Server is reading block list from: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
[2024-07-05 16:06:30 Local] DNS Server successfully loaded DNS application: Query Logs (Sqlite)
[2024-07-05 16:06:30 Local] [[::]:5380] [HTTP] Web Service was bound successfully.
[2024-07-05 16:06:30 Local] [0.0.0.0:53] [UDP] DNS Server was bound successfully.
[2024-07-05 16:06:30 Local] [0.0.0.0:53] [TCP] DNS Server was bound successfully.
[2024-07-05 16:06:30 Local] [[::]:53] [UDP] DNS Server was bound successfully.
[2024-07-05 16:06:30 Local] [[::]:53] [TCP] DNS Server was bound successfully.
[2024-07-05 16:06:30 Local] DHCP Server successfully loaded scope: Default
[2024-07-05 16:06:30 Local] DHCP Server successfully loaded scope file: /etc/dns/scopes/Default.scope
[2024-07-05 16:06:30 Local] DNS Server (v12.2.1.0) was started successfully.
[2024-07-05 16:06:30 Local] DNS Server read block list file (165492 domains) from: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
[2024-07-05 16:06:30 Local] DNS Server is reading block list from: https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
[2024-07-05 16:06:30 Local] DNS Server read block list file (34 domains) from: https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
[2024-07-05 16:06:30 Local] DNS Server is reading block list from: https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
[2024-07-05 16:06:30 Local] DNS Server read block list file (2701 domains) from: https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
[2024-07-05 16:06:30 Local] DNS Server block list zone was loaded successfully.
ShreyasZare commented 2 months ago

Nope, no error, here is what I see :

The API just lists the *.log files in the logs folder. Just check the Settings > Logging section to see if there is a different Log Folder Path configured. By default it should be just logs in there which will get expanded relatively.

Worst case, I remove them all because normally, it is a duplicate of SQLite logs no?

Yes, the query logs will be the same that you already have in Sqlite.

EHRETic commented 2 months ago

. Just check the Settings > Logging section to see if there is a different Log Folder Path configured. By default it should be just logs in there which will get expanded relatively.

As usual, impeccable support from you guys, it was still pointing to old location! Thanks a lot ๐Ÿ˜‰

ShreyasZare commented 2 months ago

You're welcome. Good to know that its working!

EHRETic commented 2 months ago

Still my home environment but I love this software so much!

EHRETic commented 2 months ago

(and the difficulties I got today also translate since when...)