GOOD_PRACTICES.t2t 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. Good practices for imapsync
  2. Gilles LAMIRAL gilles@lamiral.info
  3. % $Id: GOOD_PRACTICES.t2t,v 1.10 2019/11/25 12:50:54 gilles Exp gilles $
  4. = Good practices for imapsync =
  5. You are not supposed to have read the TUTORIAL documentation but
  6. reading it should help to understand and master the following best practices.
  7. == Simple transfer ==
  8. By principle, imapsync does not change any single byte of messages,
  9. unless --regexmess or --addheader is used.
  10. Imapsync identifies messages with "Message-Id" and "Received" headers,
  11. so it ignores messages that lack those headers;
  12. most of the time it happens with the "Sent" folders.
  13. A way to sync those messages is to add option --addheader.
  14. Before appending a message on host2, and only when needed,
  15. --addheader option adds a Message-Id header like "Message-Id: <123456789@imapsync>"
  16. where 123456789 is the host1 folder message UID. Messages on host1 stay untouched.
  17. This way, multiples runs will not generate duplicates as long as UIDs stay
  18. the same on host1, which is the case for most imap servers.
  19. Unix:
  20. ```
  21. imapsync \
  22. --host1 imap.truc.org --user1 foo --password1 secret1 \
  23. --host2 imap.trac.org --user2 bar --password2 secret2 \
  24. --addheader
  25. ```
  26. Windows:
  27. ```
  28. imapsync ^
  29. --host1 imap.truc.org --user1 foo --password1 secret1 ^
  30. --host2 imap.trac.org --user2 bar --password2 secret2 ^
  31. --addheader
  32. ```
  33. == Exact backup ==
  34. Assertions for this example:
  35. - The target account at host2 is considered like inactive.
  36. - Everything a user does on host1 will be synced, folders, messages, flags.
  37. - Everything a user does on host2 will be erased by the sync.
  38. Two options are good for an exact backup, --delete2 and --delete2folders.
  39. - --delete2: deletes messages in host2 that are not in host1 server.
  40. - --delete2folders: deletes folders in host2 that are not in host1 server.
  41. Unix:
  42. ```
  43. imapsync \
  44. --host1 imap.truc.org --user1 foo --password1 secret1 \
  45. --host2 imap.trac.org --user2 bar --password2 secret2 \
  46. --delete2 --delete2folders
  47. ```
  48. Windows:
  49. ```
  50. imapsync ^
  51. --host1 imap.truc.org --user1 foo --password1 secret1 ^
  52. --host2 imap.trac.org --user2 bar --password2 secret2 ^
  53. --delete2 --delete2folders
  54. ```
  55. Have in mind
  56. - Doing backups without restoring at least one time to check the process
  57. is like pissing in a violin or throwing away your messages.
  58. - Manual backups are useless because manually you will never have the ones you need
  59. to restore, they will always be out of date.
  60. - Automatic backups are the way to go. They never forget to start. But they may fail.
  61. - Automatic backups can fail. How? Hard disks get fully filled, they crash.
  62. Networks fail too.
  63. - Monitor the backups.
  64. - Remember you have backups.
  65. - Document the restoring process or consider the backup is a just a lost trash.
  66. - Think twice at least before running any restoring command.
  67. Restoring is dangerous.
  68. == Restore ==
  69. Restoring is not the exact reverse of backupping
  70. since between a backup and a mistake, the context has changed,
  71. some things went wrong but not all, for examples new messages arrived.
  72. So synchronize an active account identical from a backup might not be the best idea.
  73. The context can be a crash or equivalent like when a
  74. not friendly admin or service closed definitevely access to your messages.
  75. Even in that case an exact restore, with --delete2 --delete2folders, should not be ok,
  76. just because new messages arrive in INBOX all the time.
  77. == Presync ==
  78. Presync is like a backup except deleting folders on host2 that
  79. are not on host1 is not always wanted. Presync means a new
  80. different imap server will host messages and folders.
  81. Often this new imap server has predefined folders that
  82. should be kept for proper use, so I suggest to not use
  83. option --delete2folders.
  84. Unix:
  85. ```
  86. imapsync \
  87. --host1 imap.truc.org --user1 foo --password1 secret1 \
  88. --host2 imap.trac.org --user2 bar --password2 secret2 \
  89. --delete2
  90. ```
  91. Windows:
  92. ```
  93. imapsync ^
  94. --host1 imap.truc.org --user1 foo --password1 secret1 ^
  95. --host2 imap.trac.org --user2 bar --password2 secret2 ^
  96. --delete2
  97. ```