imapsync unter Debian 11 installieren

Hatte imapsync vor Jahren schon erfolgreich im Einsatz. Sehr mächtiges Tool um Emailkonten zwischen zwei IMAP Servern zu migrieren/synchronisieren.
Für die Installation nutze ich ein frisch aufgesetztes und aktualisiertes Debian 12 Bookworm. (INSTALL.Debian.txt)

14.10.2023 - Anleitung aktualisiert (Debian 12 mit imapsync 2.261)
30.01.2022 - Anleitung für Debian 11 mit imapsync 2.178

imapsync CLI

benötigte Pakete intallieren

apt install -y                \
  wget                        \
  git                         \
  lsb-release                 \
  libauthen-ntlm-perl         \
  libdist-checkconflicts-perl \
  libpar-packer-perl          \
  libtest-requires-perl       \
  libtest-fatal-perl          \
  libtest-mock-guard-perl     \
  libcgi-pm-perl              \
  libcrypt-openssl-rsa-perl   \
  libdata-uniqid-perl         \
  libencode-imaputf7-perl     \
  libfile-copy-recursive-perl \
  libfile-tail-perl           \
  libio-socket-inet6-perl     \
  libio-socket-ssl-perl       \
  libio-tee-perl              \
  libhtml-parser-perl         \
  libjson-webtoken-perl       \
  libmail-imapclient-perl     \
  libparse-recdescent-perl    \
  libmodule-scandeps-perl     \
  libreadonly-perl            \
  libregexp-common-perl       \
  libsys-meminfo-perl         \
  libterm-readkey-perl        \
  libtest-mockobject-perl     \
  libtest-pod-perl            \
  libunicode-string-perl      \
  liburi-perl                 \
  libwww-perl                 \
  libtest-nowarnings-perl     \
  libtest-deep-perl           \
  libtest-warn-perl           \
  make                        \
  cpanminus

imapsync installieren (nicht ganz aktuelle Version von Github)

$ wget -N https://raw.githubusercontent.com/imapsync/imapsync/master/imapsync
$ chmod +x imapsync
$ imapsync --version
2.229

imapsync installieren (aktuellste Version von der offiziellen Website) *meine Methode*

$ wget -N https://imapsync.lamiral.info/imapsync
$ chmod +x imapsync
$ imapsync --version
2.261

die binary verschieben

$ mv imapsync /usr/bin/

imapsync Funktionstest

imapsync --tests         # Run local non-regression tests. Exit code 0 means all ok.
imapsync --testslive     # Run a live test with test1.lamiral.info imap server.

Zuerst sollte man immer einen Trockenlauf mit –dry durchführen und die Ausgaben und Statistiken kontrollieren.
SSL (–ssl und –tls) muss nicht extra mit angegeben werden. Nutzt imapsync automatisch, wenn die Server es können.

$ imapsync --dry         \
  --host1 mailserver-1   \
  --user1 emailaccount-1 \
  --password1 password-1 \
  --host2 mailserver-2   \
  --user2 emailaccount-2 \
  --password2 password-2

Wenn alles passt, kann jetzt ohne –dry migriert/synchronisiert werden.

--- SNIP ---
+++ Statistics
Transfer started on                     : Thursday 27 January 2022-01-27 20:16:38 +0000 UTC
Transfer ended on                       : Thursday 27 January 2022-01-27 20:16:56 +0000 UTC
Transfer time                           : 17.5 sec
Folders synced                          : 19/19 synced
Messages transferred                    : 20 
Messages skipped                        : 346
Messages found duplicate on host1       : 0
Messages found duplicate on host2       : 0
Messages found crossduplicate on host2  : 0
Messages void (noheader) on host1       : 0  
Messages void (noheader) on host2       : 0
Messages found in host1 not in host2    : 0 messages
Messages found in host2 not in host1    : 103 messages
Messages deleted on host1               : 0
Messages deleted on host2               : 0
Total bytes transferred                 : 403585 (394.126 KiB)
Total bytes skipped                     : 27070054 (25.816 MiB)
Message rate                            : 1.1 messages/s
Average bandwidth rate                  : 22.5 KiB/s
Reconnections to host1                  : 0
Reconnections to host2                  : 0
Memory consumption at the end           : 177.5 MiB (started with 159.3 MiB)
Load end is                             : 0.23 0.19 0.18 1/429 on 2 cores
CPU time and %cpu                       : 1.7 sec 9.7 %cpu 4.8 %allcpus
Biggest message transferred             : 146628 bytes (143.191 KiB)
Memory/biggest message ratio            : 1269.3
Start difference host2 - host1          : 83 messages, 5419803 bytes (5.169 MiB)
Final difference host2 - host1          : 103 messages, 5823388 bytes (5.554 MiB)

The sync looks good, all 366 identified messages in host1 are on host2.
There is no unidentified message on host1.
The sync is not strict, there are 103 among 469 identified messages in host2 that are not on host1. Use --delete2 and sync again to delete them and have a strict sync.
Detected 0 errors
--- SNIP ---

Das Arbeitsverzeichnis des imapsync Prozesses ist /var/tmp/imapsync_cgi. (für pid- und logfiles)

imapsync WebUI

Für imapsync kann auch das eigene Webinterface genutzt werden. (INSTALL.OnlineUI.txt)

CGI.pm sollte nicht unter der Version 4.0.8 sein

$ perl -MCGI -e 'print "$CGI::VERSION\n"'
4.55

Apache installieren und das cgid Modul aktivieren

$ apt install -y apache2
$ a2enmod cgid
$ systemctl restart apache2

imapsync ins cgi-bin Verzeichnis kopieren

$ cp /usr/bin/imapsync /usr/lib/cgi-bin/

Apache läuft unter dem Benutzer www-data. Beide Befehle müssen ohne Fehler ausgeführt werden können.

$ su -s /bin/sh -c 'SERVER_SOFTWARE=foo /usr/lib/cgi-bin/imapsync' www-data
$ wget -nv -S -O-  http://localhost/cgi-bin/imapsync?testslive=1

die Dateien für das WebUI kopieren

$ mkdir /var/www/html/imapsync/
$ cd /var/www/html/imapsync

$ wget -N \
https://imapsync.lamiral.info/X/imapsync_form_extra.html \
https://imapsync.lamiral.info/X/imapsync_form.css \
https://imapsync.lamiral.info/X/imapsync_form.js \
https://imapsync.lamiral.info/X/logo_imapsync_Xn.png

$ ln -s imapsync_form_extra.html index.html

Über die URL http://ipadresse/imapsync kann das WebUI jetzt aufgerufen werden.

3 Gedanken zu „imapsync unter Debian 11 installieren“

Schreibe einen Kommentar zu Jan Antworten abbrechen