FAQ.Use_cache.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. $Id: FAQ.Use_cache.txt,v 1.11 2021/04/22 13:20:18 gilles Exp gilles $
  2. This document is also available online at
  3. https://imapsync.lamiral.info/FAQ.d/
  4. https://imapsync.lamiral.info/FAQ.d/FAQ.Use_cache.txt
  5. =======================================================================
  6. Imapsync --usecache or --useuid options
  7. =======================================================================
  8. Questions answered in this FAQ are:
  9. Q. What is --usecache good for?
  10. Q. What is the technical principle of --usecache?
  11. Q. On Windows, with --useuid and after a reboot or a new login, a new
  12. run generates duplicates. What can I do to avoid and fix that?
  13. Q. On Windows, with --useuid or --usecache a problem occurs with long
  14. nested folder names. The error message is:
  15. "No such file or directory; The filename or extension is too long"
  16. Q. Inode problem with --usecache or --useuid on Linux
  17. Now the questions again and their answers.
  18. =======================================================================
  19. Q. What is --usecache good for?
  20. R. The option --usecache is useful to speed up next syncs with --usecache.
  21. The first sync with --usecache between two imap accounts is as low
  22. as the first sync without --usecache, the next syncs are faster.
  23. =======================================================================
  24. Q. What is the technical principle of --usecache?
  25. R. Option --usecache creates a empty file per email message
  26. in order to keep the UIDs mapping between account1 and account2.
  27. The cache is maintened at each run. Messages UIDs enregistred
  28. in the cache are not fetched again to be identified. It really
  29. speeds up the process of syncing.
  30. The cache directory is
  31. <tmpdir>/imapsync_cache/
  32. where <tmpdir> is the temporary directory given by the --tmpdir option
  33. or the one by default, /tmp on Unix, variable on Windows.
  34. =======================================================================
  35. Q. On Windows, with --useuid and after a reboot or a new login, a new
  36. run generates duplicates. What can I do to avoid and fix that?
  37. R. The cache is build in a temporary directory. Imapsync uses a system
  38. call to get this temporary directory, it is not hardcoded and it
  39. is system dependent, the call garanties a write access. Sometimes on
  40. Windows this directory name changes upon reboot or for any other reason.
  41. Anyway, the temporary directory used by imapsync can be set by the
  42. option --tmpdir and that's the way to avoid this issue.
  43. The new problem is that the temporary directory must be writable, which
  44. is not a big deal to found.
  45. Use for example either a) b) or c)
  46. a) The current directory:
  47. imapsync ... --tmpdir .
  48. b) The root directory:
  49. imapsync ... --tmpdir /
  50. c) Any directory you want, like:
  51. imapsync ... --tmpdir "C:\TEMP"
  52. Now, to fix the duplicates on host2, have a run with the option
  53. --delete2duplicates
  54. imapsync ... --delete2duplicates
  55. =======================================================================
  56. Q. On Windows, with --useuid or --usecache a problem occurs with long
  57. nested folder names. The error message is:
  58. "No such file or directory; The filename or extension is too long"
  59. R. This comes from a Windows limitation on pathnames.
  60. No more than 260 characters are allowed for pathnames.
  61. See more details on page
  62. http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#maxpath
  63. The workaround solution given at the previous link,
  64. ie using \\?\D:", does not work for imapsync.
  65. So this imapsync Windows bug is still pending and needs a fix using
  66. a different technique to cache, like a database file for example.
  67. A solution to fix the issue is to use a Linux virtual host on a
  68. Windows box, with VirtualBox or VmWare etc. There is no bug this way,
  69. pathnames can be several thousands characters long.
  70. Better said that done but not so difficult nor expensive these days,
  71. VirtualBox is free and VmWare Player is free for personal or test use.
  72. If you have to stick on Windows, there are two good workarounds
  73. to reduce the cache directory name:
  74. 1) Use --tmpdir "D:\\temp" or simply --tmpdir "D:" and imapsync
  75. will build and use the cache in the sub directory
  76. D:\imapsync_cache\
  77. 2) add two equivalent entries in the etc/hosts for host1 imap.truc.org
  78. and host2 imap.trac.org.
  79. If you map the ip of imap.truc.org just with the letter a
  80. and same thing for imap.trac.org then you gain characters
  81. etc/hosts
  82. 192.168.12.1 a
  83. 192.168.55.3 b
  84. Then use:
  85. imapsync --host1 a --host2 b ...
  86. You can get the ip of a host with the ping command line
  87. C:\> ping imap.truc.org
  88. 3) A third solution is to not use options --useuid nor --usecache
  89. Fixing this long path problem directly in imapsync is in the TODO file
  90. for a very long time.
  91. =======================================================================
  92. Q. Inode problem with --usecache or --useuid on Linux
  93. R. You may run out of inodes using --usecache, especially with large
  94. migration. Option --usecache creates a empty file per email message
  95. in order to keep the UIDs mapping between account1 and account2.
  96. So, if you plan to sync regularly 10 millions messages over a period
  97. of migration then the filesystem of --tmpdir needs 10 millions of free
  98. inodes. If it hasn't those free inodes then create a new special
  99. filesystem devoted to the imapsync cache.
  100. # Create a file of 10 GB (10 millions*1024):
  101. dd if=/dev/zero of=/var/tmp/fscache bs=1M count=10000
  102. # Create a filesystem where each file is only 1024 bytes per inode:
  103. mkfs.ext2 -F -i 1024 /var/tmp/fscache
  104. # Mount this brand new filesystem
  105. mkdir -p /var/tmp/cachedir
  106. mount -o loop /var/tmp/fscache /var/tmp/cachedir
  107. df -i /var/tmp/cachedir # count inodes available
  108. # Tell imapsync to use it
  109. imapsync ... --tmpdir /var/tmp/cachedir/
  110. # When the migration is over and the cache becomes really useless
  111. umount /var/tmp/cachedir/
  112. rm /var/tmp/fscache
  113. =======================================================================
  114. =======================================================================