Restoring emptied /etc/postfix/virtual using rebuild-map

SYSTEM INFORMATION
OS type and version Ubuntu Linux 20.04.6
Webmin version 2.621
Usermin version 2.521
Virtualmin version 8.1.0 GPL
Theme version 26.22
Apache version 2.4.41
Package updates All installed packages are up to date

Hi, I accidentally emptied my /etc/postfix/virtual file. I am planning to run virtualmin rebuild-maps --all-domains to regenerate it.

My questions are:

  1. Does this command strictly only touch Postfix related files in /etc/postfix/?
  2. Is there any risk of it affecting other Virtualmin configurations or website files?
  3. Should I run any other command (like postmap) manually after this?

Thanks for your help!

Oh wait, you deleted the text file that is used to do the re-build, that won’t work.

Ok, found a command to dump to text called db_dump

I haven’t test yet if it still available.

I accidentally emptied my ā€œ/etc/postfix/virtualā€ file. How can I regenerate this file from Virtualmin’s own database? Is ā€œvirtualmin rebuild-maps --all-domainsā€ the right command for this, and is it safe to run?

no it isn’t, that’s for creating the db file.

BTW I don’t have db_dump on my server, but don’t do any rebuild

Backup your current virtual.db, you don’t wont to loss that.

Wait, I thought postmap was the one for creating the .db file from the text file.

Doesn’t virtualmin rebuild-maps actually generate the text content itself by pulling data from Virtualmin’s own configs? If not, how am I supposed to fill that empty text file back up?

Thats right, virtual is a text file, virtual.db is the build.

Trying to find docs on it.

Exactly. So since my virtual text file is now empty, I need a way to refill it using Virtualmin’s own database.

Is virtualmin rebuild-maps --all-domains the right command to regenerate that text file content? Or is there another way to tell Virtualmin to write its current alias list back into /etc/postfix/virtual?

No, because it builds maps, you need the text files for that.

I think there’s a misunderstanding. I’m not trying to build the .db file from the text file. I know postmap does that.

My problem is the /etc/postfix/virtual text file itself is empty. I need Virtualmin to look at its own database (where it stores alias/domain info) and rewrite the content into that empty text file. I believe virtualmin rebuild-maps --all-domains is designed to do this sync. Is that correct? If not, how can I trigger Virtualmin to ā€˜re-export’ its internal alias list back into the text file?

No its like the command says, it rebuilds, its for when a .db file/s are corrupt.

OK found the command

postmap -s virtual > virtual.txt

try that, please backup your virtual.db first though.

Thanks, but postmap -s only works if the .db file is intact. In my case, the .db file is also corrupted because the source text file was emptied. I don’t want to extract data from Postfix; I need Virtualmin to push its own internal data into Postfix.

I’m pretty sure virtualmin rebuild-maps --all-domains is the command that handles this sync by pulling from Virtualmin’s metadata. I just want to be 100% sure that running it won’t touch or break anything else outside of the /etc/postfix folder. That’s my main concern.

what size is your virtual.db?
virtual.db doesn’t need virtual for postfix to work, its only use to build virtual.db, unless you did a rebuild after you lost the content of virtual (then your pretty much stuffed).

did you try running the command?

Vitualmin rebuld-maps would just use the postmap commands, its a script design to make life easier for virtuamin users, don’t overthink it.

Also Virtuamin is just GUI to configure your server, its not the server it dosn’t store that info in its config’s, its just reading from the postfix config files. If you stop Virtualmin your server still keeps running.

BTW I don’t think thats a valid command, I can’t see it in the list of commands and if I run it it errors.


where did you find it?

Maybe its call rebuild-maps and not rebuild-map

I tried both, I see no docs on it either.

Does this help? It mentions ā€œvirtualmin-config-system -i Postfixā€

Yeah, that not the command, I think it maybe a AI solution that doesn’t exist.
Copolit explained to me what it did, and the command doesn’t exist.

I remember losing a file in my /etc before and found that Virtualmin (or something) kept backups of the entire /etc folder for me… so I was able to restore… but I can’t remember what it was.

That’s an idea restore the file usig etckeeper which I think you referring to