# E-Mail-Postfächer Migration/Synchronisierung mit IMAPSync unter Ubuntu (WSL2 geeignet)

<span style="white-space: pre-wrap;">Im Blogpost von Claudio Kuenzler wird </span>**imapsync**<span style="white-space: pre-wrap;"> als robustes CLI-Werkzeug vorgestellt, um IMAP-Postfächer verlustfrei zu migrieren bzw. zu sichern. Der Artikel zeigt:</span>

- **Dry-Run**<span style="white-space: pre-wrap;"> mit </span>`<span class="editor-theme-code">--dry</span>`<span style="white-space: pre-wrap;"> zum sicheren Probelauf inkl. Statistik.</span>
- <span style="white-space: pre-wrap;">Vollständigen </span>**Produktivlauf**<span style="white-space: pre-wrap;"> ohne </span>`<span class="editor-theme-code">--dry</span>`.
- <span style="white-space: pre-wrap;">Typische Optionen wie </span>`<span class="editor-theme-code">--automap</span>`<span style="white-space: pre-wrap;"> (Ordner-Mapping), </span>`<span class="editor-theme-code">--useuid</span>`<span style="white-space: pre-wrap;"> (duplikatfreies, inkrementelles Syncing), </span>`<span class="editor-theme-code">--syncinternaldates</span>`<span style="white-space: pre-wrap;"> (Originalzeiten behalten), </span>`<span class="editor-theme-code">--addheader</span>`<span style="white-space: pre-wrap;"> (für Nachrichten ohne eindeutige Header).</span>
- <span style="white-space: pre-wrap;">Paket-/Modul-Voraussetzungen und die Empfehlung, jeweils die </span>**neueste**<span style="white-space: pre-wrap;"> Version zu nutzen (der Artikel selbst verwendet 1.977, Stand 2021).</span>

<span style="white-space: pre-wrap;">Quelle: </span>[https://www.claudiokuenzler.com/blog/1038/email-migration-transfer-sync-using-imap-mailbox-imapsync](https://www.claudiokuenzler.com/blog/1038/email-migration-transfer-sync-using-imap-mailbox-imapsync)

## Vorbereitung (Passwortdateien sicher anlegen)

> <span style="white-space: pre-wrap;">Ziel: </span>`<span class="editor-theme-code">ionos.pw</span>`<span style="white-space: pre-wrap;"> und </span>`<span class="editor-theme-code">hetzner.pw</span>`<span style="white-space: pre-wrap;"> mit je </span>**nur**<span style="white-space: pre-wrap;"> der Passphrase in Zeile 1, restriktive Rechte.</span>

```bash
# Create secrets dir with strict permissions
mkdir -p ~/secrets
chmod 700 ~/secrets

# Create ionos password file securely
nano ~/secrets/ionos.pw
# Paste the IONOS password on line 1, save & exit (Ctrl+O, Enter, Ctrl+X)

# Create hetzner password file if not already present
nano ~/secrets/hetzner.pw
# Paste the Hetzner password on line 1, save & exit

# Restrict file permissions
chmod 600 ~/secrets/ionos.pw ~/secrets/hetzner.pw
```

**Warum Passfile?**<span style="white-space: pre-wrap;"> </span>`<span class="editor-theme-code">--passfile1/2</span>`<span style="white-space: pre-wrap;"> vermeidet Klartext-Passwörter in der Prozessliste/History. (Siehe imapsync-README zu </span>`<span class="editor-theme-code">--passfile1/--passfile2</span>`<span style="white-space: pre-wrap;">.) </span>[GitHub](https://github.com/imapsync/imapsync)

---

## Optional: Installation/Update auf die neueste Version

**Variante A (Debian/Ubuntu, empfohlen):**

```bash
# Download the latest Debian package listed in the official dist2 index
cd /tmp
wget https://imapsync.lamiral.info/dist2/imapsync-2.309.deb
sudo apt install ./imapsync-2.309.deb
```

[https://imapsync.lamiral.info/dist2/](https://imapsync.lamiral.info/dist2/)

**Variante B (Universell, Tarball/Source):**

```bash
# Get the current tarball release
cd ~/build && mkdir -p imapsync && cd imapsync
wget https://imapsync.lamiral.info/dist2/imapsync-2.290.tgz
tar xzf imapsync-2.290.tgz
# The executable script is ./imapsync inside the extracted folder
```

[https://imapsync.lamiral.info/dist2/](https://imapsync.lamiral.info/dist2/)

<p class="callout info"><span style="white-space: pre-wrap;">Angefügt ist ebenfalls die zuletzt verwendete Version: </span>[imapsync-imapsync-2.229.tar.gz](https://bookstack.familie-boexler.de/attachments/35)</p>

> Hinweis zu Perl-Modulen: Falls Abhängigkeiten fehlen, siehe INSTALL/TUTORIAL der offiziellen Doku.
> 
> [https://imapsync.lamiral.info/INSTALL?utm\_source=chatgpt.com](https://imapsync.lamiral.info/INSTALL?utm_source=chatgpt.com)

---

## **Dry-Run**<span style="white-space: pre-wrap;"> (sichere Simulation, keine Änderungen)</span>

```bash
# DRY RUN: simulate IONOS -> Hetzner migration without transferring messages
./imapsync \
  --dry \
  --host1 imap.ionos.com --user1 'info@Schule-Freudenberg.de' --passfile1 ~/secrets/ionos.pw --ssl1 \
  --host2 mail.your-server.de --user2 'kontakt@Schule-Freudenberg.de' --passfile2 ~/secrets/hetzner.pw --ssl2 \
  --automap \
  --useuid \
  --syncinternaldates \
  --addheader \
  --exclude '(?i)spam|trash|junk' \
  --logfile ~/imapsync_ionos_to_hetzner_dry.log
```

- `<span class="editor-theme-code">--dry</span>`<span style="white-space: pre-wrap;"> zeigt, was </span>**passieren würde**, inkl. Ordner-/Nachrichtenstatistik, aber ohne echte Übertragung. (Wie im Artikel demonstriert.)
- `<span class="editor-theme-code">--automap</span>`<span style="white-space: pre-wrap;"> erkennt/ordnet Standardordner (Sent/Trash/Junk/Drafts/Archive/Flagged) automatisch zu.</span>
- `<span class="editor-theme-code">--useuid</span>`<span style="white-space: pre-wrap;"> und </span>`<span class="editor-theme-code">--addheader</span>`<span style="white-space: pre-wrap;"> minimieren Dubletten und helfen bei Entwürfen/Gesendet-Mails ohne eindeutige Header.</span>
- `<span class="editor-theme-code">--syncinternaldates</span>`<span style="white-space: pre-wrap;"> erhält interne Serverzeiten (Anzeige bleibt konsistent). (Im Artikel erläutert.)</span>
- `<span class="editor-theme-code">--exclude '(?i)spam|trash|junk'</span>`<span style="white-space: pre-wrap;"> lässt offensichtliche Systemordner aus. (Ordner-Selektion siehe FAQ.)</span>

---

## **Produktivlauf**<span style="white-space: pre-wrap;"> (tatsächliche Migration)</span>

```bash
# REAL RUN: perform IONOS -> Hetzner migration
./imapsync \
  --host1 imap.ionos.com --user1 'info@Schule-Freudenberg.de' --passfile1 ~/secrets/ionos.pw --ssl1 \
  --host2 mail.your-server.de --user2 'kontakt@Schule-Freudenberg.de' --passfile2 ~/secrets/hetzner.pw --ssl2 \
  --automap \
  --useuid \
  --syncinternaldates \
  --addheader \
  --exclude '(?i)spam|trash|junk' \
  --logfile ~/imapsync_ionos_to_hetzner.log
```

> <span style="white-space: pre-wrap;">Tipp: Wer zusätzlich nur die Ordner-Zuordnung prüfen will, kann einmalig </span>`<span class="editor-theme-code">--automap --justautomap</span>`<span style="white-space: pre-wrap;"> testen (ohne Nachrichtenübertrag). </span>[https://imapsync.lamiral.info/S/news.shtml?utm\_source=chatgpt.com](https://imapsync.lamiral.info/S/news.shtml?utm_source=chatgpt.com)

---

## Ergebnisse prüfen &amp; typische Hinweise

- **Logs**: Lies die Logdatei (`<span class="editor-theme-code">--logfile …</span>`). Ein guter Abschluss wird explizit gemeldet („The sync looks good … Detected 0 errors“).
- **SSL/Ports**<span style="white-space: pre-wrap;">: IONOS IMAP via </span>**993/SSL**<span style="white-space: pre-wrap;">, Hetzner via </span>**993/SSL**<span style="white-space: pre-wrap;"> — unsere Befehle erzwingen SSL mit </span>`<span class="editor-theme-code">--ssl1/--ssl2</span>`.
- **Mehrfachläufe**<span style="white-space: pre-wrap;">: imapsync ist </span>**inkrementell**<span style="white-space: pre-wrap;">; wiederholte Läufe übertragen nur Diff, keine Dubletten (mit </span>`<span class="editor-theme-code">--useuid</span>`).