
我有兩台在 Ubuntu 14.04 上運行的伺服器。兩者均安裝了 Postfix 和 Dovcote。郵件伺服器在兩者上均運作正常。我想將郵件從伺服器 1 傳輸到伺服器 2 。任何人都可以建議該程序
答案1
您可以使用帶有“imapsync”的腳本來傳輸它們,她是我用於遷移到Google郵件的腳本。它可以與任何 imap 就緒的郵件伺服器一起使用:
SERVER1=imap.source.com
SERVER2=imap.dest.com
#Uncomment to hide folder sizes
FAST="--nofoldersizes"
#Uncomment to do a dry run (no actual changes)
#DRY="--dry"
#Uncomment to just sync folders (no messages)
#JUSTFOLDERS="--justfolders"
#Uncomment to just connect (no syncs at all)
#JUSTCONNECT="--justconnect"
#Set the path to your imapsync binary
imapsync=imapsync
#Users file
if [ -z "$1" ]
then
echo "No users text file given."
exit
fi
if [ ! -f "$1" ]
then
echo "Given users text file \"$1\" does not exist"
exit
fi
while IFS=';' read u1 p1 u2 p2; do {
$imapsync --usecache --syncinternaldates --nosyncacls --tmpdir /var/tmp --host1 ${SERVER1} --user1 "$u1" --password1 "$p1" --host2 ${SERVER2} --port2 993 --user2 "$u2" --password2 "$p2" --ssl2 ${FAST} ${DRY} ${JUSTFOLDERS} ${JUSTCONNECT} --exclude "Sent|^Delet|Drafts|Spam|Calendar|Brouillons|^Calend|envoi|^Contacts|Flux|sirable|Flux RSS|^Historiqu|Infected|Journal|Junk|LinkedIn|Notes|Outbox|^Probl|supprim|Courrier ind&AOk-sirable" --regextrans2 "s,^&AMk-l&AOk-ments envoy&AOk-s$,[Gmail]/Messages envoy&AOk-s," --regextrans2 "s,^INBOX/,," --regextrans2 's{Sent Items$}{[Gmail]/Messages envoy&AOk-s}' --regextrans2 's{Sent Messages$}{[Gmail]/Messages envoy&AOk-s}' --regextrans2 's{&AMk-l&AOk-ments envoy&AOk-s$}{[Gmail]/Messages envoy&AOk-s}' --regextrans2 's{Éléments envoyés$}{[Gmail]/Messages envoy&AOk-s}'
}
done < $1
啟動腳本的命令列是
./script.sh sample.txt
其中sample.txt是包含兩台伺服器的每個使用者的位址和密碼的檔案:
[email protected];password1;[email protected];password2