A robust, interactive Bash wrapper for imapsync. This tool provides a user-friendly CLI menu to migrate email accounts between servers.
It handles background processing, logging, connection stability, and security automatically, so you don't have to memorize complex CLI flags.
- Interactive Menu: No need to type long commands or CSV files. Just follow the prompts.
- Background Processing: Migrations run in the background (detached). You can close your terminal without killing the migration.
- Performance Optimized: Uses
--useheaderand--skipcrossduplicatesfor maximum speed (skips downloading full bodies if headers match). - Live Monitoring: View real-time logs of active migrations without interrupting them.
- PID Tracking: Smart tracking system that knows exactly which migrations are running and which have finished.
- Secure & Self-Cleaning: Passwords are stored in temporary, permission-locked files (
chmod 600) and are automatically deleted the moment the migration finishes or fails.
This tool requires imapsync to be installed on your system.
Ubuntu / Debian:
cd /tmp/
wget https://imapsync.lamiral.info/dist2/imapsync.deb
sudo apt install ./imapsync.debCentOS / AlmaLinux / Rocky Linux / CloudLinux:
First, enable the EPEL repository (if not already enabled):
sudo dnf install epel-releaseThen install imapsync:
sudo dnf install imapsyncThe tool uses standard Linux commands (ps, grep, awk, tail). These are usually pre-installed. If you encounter issues viewing logs, ensure less is installed.
Clone this repository or copy and paste the script into migration_tool.sh.
Make the script executable:
chmod +x migration_tool.shRun the tool from your terminal:
./migration_tool.sh- Start new migration:
- Prompts for Source (Host1) and Destination (Host2) details.
- Automatically validates credentials (
--justlogin) before starting. - Starts the migration in the background and schedules immediate password cleanup.
- View ACTIVE logs:
- Shows a list of currently running migrations.
- Select one to view its live progress.
- Press
qto return to the menu (does not stop the migration).
- View HISTORY:
- View logs of completed or failed migrations.
- Delete old logs:
- Cleans up the log directory.
This script applies the following imapsync optimizations by default:
--useheader "Message-Id": Huge speed boost. Compares emails by Header ID instead of body size/content. Essential when migrating between different server types.--syncinternaldates: Preserves the original date/time of emails.--resyncflags: Preserves Read/Unread/Replied status.--skipcrossduplicates: Prevents checking across different folders (saves CPU).--delete2duplicates: Ensures the destination folder doesn't contain duplicates.
The script creates two hidden folders in its running directory:
./imapsync_logs/: Contains the output logs for every migration../.imapsync_secrets/: Temporarily stores password files and the active process tracker (cleaned up automatically).