maxisam / mgob

MongoDB dockerized backup agent. Runs schedule backups with retention, S3 & SFTP upload, notifications, instrumentation with Prometheus and more.
https://maxisam.github.io/mgob/
MIT License
123 stars 16 forks source link

Error sending notification email #62

Closed joeldatabox closed 10 months ago

joeldatabox commented 1 year ago

I have a problem with sending notifications. Right after running the backup I always come across the following error below:

mgob-backup-manager | time="2023-06-09T07:23:53Z" level=info msg="Backup finished in 4h23m53.110717758s archive mydatabase-1686279600.gz size 2.1 GB" plan=mydatabase mgob-backup-manager | time="2023-06-09T07:28:13Z" level=error msg="Notifier failed sending email notification failed: dial tcp 191.6.216.100:587: connect: connection timed out" plan=mydatabase mgob-backup-manager | time="2023-06-09T07:28:13Z" level=info msg="Next run at 2023-06-10 03:00:00 +0000 UTC" plan=mydatabase

Detail: Before making the settings for production, I created an example for validation and testing. During the tests the database had almost no data and right after the backup I always received the email smoothly.

What could be happening?

woraccmsq commented 1 year ago

I also have an issue with e-mail sending: time="2023-06-14T01:00:41Z" level=error msg="Notifier failed sending email notification failed: x509: certificate signed by unknown authority"

maxisam commented 11 months ago

@joeldatabox it seems like it has an issue on connection

Notifier failed sending email notification failed: dial tcp 191.6.216.100:587: connect: connection timed out.

Do you have the same setup for testing and production?

maxisam commented 11 months ago

@woraccmsq for your smtp settings

      smtp:
        server: xxx
        warnOnly: true
        insecureSkipVerify: true # <-- this is the setting for your issue
        tlsEnabled: true
        port: 25
joeldatabox commented 11 months ago

Apologies for the delay. @maxisam follow the current production settings.

docker-compose.yml

docker-compose.yml
version: "3.8"
services:
  my-cloud-backup-manager:
    restart: always
    image: maxisam/mgob:latest
    networks:
      - my-cloud-backup-manager-network
      - my-cloud-backup-network
      - my-cloud-proxy-network
    ports:
      - "8090"
    volumes:
      - ./my-cloud-backup-files/config:/config
      - ./my-cloud-backup-files/storage:/storage
      - ./my-cloud-backup-files/tmp:/tmp
      - ./my-cloud-backup-files/data:/data
      - ./my-cloud-backup-files/keys:/secret

networks:
  my-cloud-backup-manager-network:
    driver: bridge
  my-cloud-backup-network:
    name: my-cloud-backup-network
  my-cloud-proxy-network:
    name: my-cloud-proxy-network

config/my-cloud.yml

scheduler:
  # run every day at 6:00 and 18:00 UTC
  cron: "0 3 * * *"
  # number of backups to keep locally
  retention: 10
  # backup operation timeout in minutes
  timeout: 720
target:
  # mongod IP or host name
  host: "my-cloud-mongodb-prod"
  # mongodb port
  port: 27017
  # mongodb database name, leave blank to backup all databases
  database: "my-cloud"
  # leave blank if auth is not enabled
  username: "root"
  password: "my-cloud-passwd"
  # add custom params to mongodump (eg. Auth or SSL support), leave blank if not needed
  #params: "--ssl --authenticationDatabase admin"
#retry:
  # number of retries
#  attempts: 3
  # backoff factor  * (2 ^ attemptCount) seconds
#  backoffFactor: 60
encryption:
  gpg:
    keyFile: /secret/key-gpg.pub
sftp:
  host: my-cloud.myhost
  port: 7586
  username: my-user-name
  password: my-passwd
  # you can also specify path to a private key and a passphrase
  # dir must exist on the SFTP server
  dir: company/my-cloud
smtp:
  server: smtp.kinghost.net
  port: 587
  username: backup@mycloud.com.br
  password: my-passwd-backup
  from: backup@mycloud.com.br
  to:
    - myemail@mycloud.com.br
    - ti@mycloud.com.br
  # 'true' to notify only on failures
  warnOnly: false

These are my production settings. I just changed the sensitive information. It is worth remembering that this same configuration works when the database is empty, however, after restoring the data the problem begins to occur.

The backup file generated when the error occurs is approximately 2.2GB in size

joeldatabox commented 10 months ago

Don't ask me how or why, but email notifications started to be sent successfully about 2 days ago.