尝试使用courier-imap和imapsync备份GMail的All Mail文件夹,到了一定阶段,mutt登录总是失败,报内存不足的错误。后来检查imapsync的log,发现也出现无法分配内存的错误。于是上网搜,发现docker并没有对内存进行任何限制。那问题出在哪里呢?
原来是courier-imap在限制内存使用,以下是一段在/etc/courier-imap/imapd里面关于参数IMAP_ULIMITD的注释。
The default value of 65536 sets a very generous limit of 64 megabytes, which should be more than plenty for anyone.
… It is theoretically possible that obscenely huge folders will also result in the server running out of memory when doing server-side sorting (by my calculations you have to have at least 100,000 messages in a single folder, for that to happen)
在出现问题的时候All Mail文件夹里已经有31万多封邮件了,全部备份完毕的时候有41万多。于是将限额增加到1G,同时将imapsync timout时间从2分钟增加到10分钟,终于备份了完整的All Mail。