1 (edited by gilles.quenot 2019-04-12 18:27:26)

Topic: Tons of contacts dupes after restor sogo

- iRedMail 0.9.9
- Linux debian9
- Store mail accounts in MariaDB
- Web server Nginx



my backup file (done by iredmail sogo backup script) is 55MB.

What I have done :

sogo-tool restore -p ./dir <name@domain.tld>
sogo-tool restore -f ALL ./dir <name@domain.tld>

It takes =~5 hours to restore with sogo-tool restore -f ALL ./dir name

Now I have tons of contacts dupes in sogo UI, I have > 200000 contacts where I had around 1000 contacts.

Is it a known issue ? Is there a solution to remove dupes ?

Regards, GQ


Re: Tons of contacts dupes after restor sogo

Possible solutions:

1) Do you have backup file which was generated by /var/vmail/backup/backup_mysql.sh? Check /var/vmail/backup/mysql/. If old SOGo is same version as the one running on current system, you have restore the sql file with sql command like "mysql sogo < /path/to/backup.sql". Then recreate SQL VIEW "sogo.users".

2) Use my script:

#!/usr/bin/env bash
# Author: Zhang Huangbin <zhb@iredmail.org>
# Usage: bash restore-sogo.sh /path/to/sogo/backup/dir /etc/sogo/sieve.cred

export PATH="/usr/local/GNUstep/Local/Tools/Admin:$PATH"

# The directory contains backup files generated by 'sogo-tool'.


[ -d ${BACKUPDIR} ] || (echo "Directory doesn't exist: ${BACKUPDIR}"; exit 255)
[ -f ${SIEVE_CREDENTIAL} ] || (echo "File doesn't exist: ${SIEVE_CREDENTIAL}"; exit 255)


for user in $(ls); do
    echo "* Restoring ${user} - 1"
    ${CMD_SOGO_TOOL} restore -f ALL ${BACKUPDIR} ${user}
    ${CMD_SOGO_TOOL} restore -p ${BACKUPDIR} ${user}

echo "* Restarting memcached service."
service memcached restart
for user in $(ls); do
    echo "* Restoring ${user} - 2"
    ${CMD_SOGO_TOOL} restore -p ${BACKUPDIR} ${user}

# For Sieve rules
for user in $(ls); do
    echo "* Restoring sieve rules for user: ${user}"
    ${CMD_SOGO_TOOL} restore -p -c ${SIEVE_CREDENTIAL} ${BACKUPDIR} ${user}

Save above code as file "restore-sogo.sh". Sample usage:

bash restore-sogo.sh /var/vmail/backup/sogo/2019/04/03/ /etc/sogo/sieve.cred

Note: file /etc/sogo/sieve.cred must contain a Dovecot master user.


Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee