Jonuji

  • 4 days ago
  • Joined 4 days ago
  • 1 discussion
  • 5 posts
  • 0 best answers
  • Post posted... wait what?
  • DocFraggle Yea so I tried it just with cur directorys (also .Sent/cur …) and it still returns an error. Maybe I’ll try to not just import the mailbox but maybe the whole _data? (or somehow anything like that).

    I also can’t find any other method. Idk anymore :/

    • DocFraggle I tried it right now and yea it did work perfectly fine mhh

      DocFraggle should I maybe not replace the mail inbox but just add the old files?

      But I probably tried this too and there the mailbox was working but not displaying the old mails idk

    • DocFraggle
      So now there is another error in the dovecot container, also after restarting and down/up:
      dovecot-mailcow-1 | Apr 7 12:22:29 f6317d05ceed dovecot: pop3-login: Disconnected: Disconnected: Too many bad commands (no auth attempts in 0 secs): user=<>, rip=199.45.155.110, lip=172.22.1.250

      My steps

      • Decrypting -> works directly and I can also manually read the content
      • Transfer to new instance with fresh mailcow
      • replaced mailbox “xxx” with the old “xxx” (not domain, it was a mailbox)
      • ran the docker dovecot with the commands and encrypted it
      • docker compose down/up

      Result: SOGo:

      An error occured while communicating with the mail server

      (and the error above)
      What I also did before that (Deleted: Created a snapshot beforehand and recovered):

      • Decrypting
      • Transfer
      • Encrypting with local dovecot
      • Moved 2 mailboxes (whole domain) to the /var/lib/docker/volumes/mailcowdockerized_crypt-vol-1/_data/ path (Important: Files were not replaced, just new were added)
      • docker compose down/up

      Result: no old mails are showing up in my inbox

      Edit: I tried to prove that it’s encrypted and yea it looks like I can’t read it with just printing it out like while decrypted.. so this shouldn’t be the problem tho

    • DocFraggle Thank you really much! The decrypting worked.

      Just wanted to ask: If I want to encrypt it again: which steps are there?
      Like: would I replace the new folder with the old or just update something? I really don’t know. I see the guide with how to encrypt it, but I’m not sure if I would do everything right?

      But thank you for your help until now!

      • Hey guys!

        So after the new update (2025-03a) I had some database issues and needed to reset the whole mail server.
        I mainly used one inbox with about 300 mails.

        Is there any way (I’ve got an snapshot of the broken server) to backup/recover these emails somehow?

        If so: how and with what?
        There are recover options for SOGo and deleted inboxes, but they aren’t deleted so they wouldn’t be there tho.

        Please help! 🙂

        (I’ve learned from my lesson and backup now..)

        • DocFraggle replied to this.
        • Jonuji You would need to decrypt all files in your old vmail directory of the snapshot using the old private key, then reencrypt them with the new private key and move them to your new vmail directory.

          See https://docs.mailcow.email/manual-guides/Dovecot/u_e-dovecot-mail-crypt/

          As the above examples are done inside the dovecot container you would need to do the decryption from the snapshot host system, so install dovecot to be able to use doveadm, and alter the path for “public_key_path” and “private_key_path” (located at /var/lib/docker/volumes/mailcowdockerized_crypt-vol-1/data/) and the search base to “/var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/data”

          So decrypting on the broken host system should look like

          cd /var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data
          
          find /var/lib/docker/volumes/mailcowdockerized_vmail-vol-1/_data/ -type f -regextype egrep -regex '.*S=.*W=.*' | while read -r file; do
          if [[ $(head -c7 "$file") == "CRYPTED" ]]; then
          doveadm fs get compress lz4:1:crypt:private_key_path=/var/lib/docker/volumes/mailcowdockerized_crypt-vol-1/_data/ecprivkey.pem:public_key_path=/var/lib/docker/volumes/mailcowdockerized_crypt-vol-1/_data/ecpubkey.pem:posix:prefix=/ \
            "$file" > "/tmp/$(basename "$file")"
            if [[ -s "/tmp/$(basename "$file")" ]]; then
              chmod 600 "/tmp/$(basename "$file")"
              chown 5000:5000 "/tmp/$(basename "$file")"
              mv "/tmp/$(basename "$file")" "$file"
            else
              rm "/tmp/$(basename "$file")"
            fi
          fi
          done

          No guarantees though