FAQ.Archiving.txt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #!/bin/cat
  2. $Id: FAQ.Archiving.txt,v 1.27 2022/05/19 08:56:06 gilles Exp gilles $
  3. This documentation is also available online at
  4. https://imapsync.lamiral.info/FAQ.d/
  5. https://imapsync.lamiral.info/FAQ.d/FAQ.Archiving.txt
  6. =======================================================================
  7. Imapsync issues and tips about archiving
  8. =======================================================================
  9. Questions answered in this FAQ are:
  10. Q. How can I archive different accounts on the same destination account,
  11. each account on a separate folder?
  12. Q. How can I restore a complete account backuped in a subfolder, like
  13. a backup done with the option --subfolder2?
  14. Q. How to move emails from one IMAP folder to another, either on the
  15. same IMAP server or on a different one? Example:
  16. How to move all messages older than 1 year, from INBOX to Archive?
  17. Q. Can imapsync be used to maintain and restore a local offline copy
  18. of a mailbox, eg for backup purposes, using Mbox or Maildir
  19. format, so that if the server fails, then the mailbox could be
  20. reinstated?
  21. Q. How to archive a whole year in a subfolder?
  22. Q. How to archive a whole year in subfolders but without subsubfolders?
  23. Now the questions again with their answers.
  24. https://imapsync.lamiral.info/FAQ.d/FAQ.Archiving.txt
  25. =======================================================================
  26. Q. How can I archive different accounts on the same destination account,
  27. each account on a separate folder?
  28. R. Use --subfolder2
  29. --subfolder2 str : Syncs the whole host1 folders hierarchy under the
  30. host2 given folder str.
  31. (It does it internally by adding two --regextrans2
  32. options before all others.)
  33. Examples:
  34. To backup the account Foo in a subfolder called FooArchiv:
  35. imapsync ... --user1 Foo --subfolder2 FooArchiv
  36. To backup the account Bar in a subfolder called BarArchiv:
  37. imapsync ... --user1 Bar --subfolder2 BarArchiv
  38. In case you need a very strict sync, add options
  39. --delete2 --delete2foldersonly "FooArchiv"
  40. (or "BarArchiv" for the second example).
  41. It will delete on account2 what is not on account1 but only in the right place,
  42. ie, the subfolder "FooArchiv".
  43. Examples:
  44. To mirror the account Foo in a subfolder called FooArchiv:
  45. imapsync ... --user1 Foo --subfolder2 FooArchiv --delete2 --delete2foldersonly "FooArchiv"
  46. To mirror the account Bar in a subfolder called BarArchiv:
  47. imapsync ... --user1 Bar --subfolder2 BarArchiv --delete2 --delete2foldersonly "BarArchiv"
  48. See how to restore those with the next Q/R.
  49. =======================================================================
  50. Q. How can I restore a complete account backuped in a subfolder, like
  51. a backup done with the option --subfolder2?
  52. R. Use --subfolder1
  53. --subfolder1 str : Syncs the host1 folders hierarchy under folder str
  54. to the root hierarchy of host2.
  55. It's the couterpart of a sync done by --subfolder2
  56. when doing it in the reverse order.
  57. Backup/Restore scenario:
  58. Use --subfolder2 str for a backup to the folder str
  59. on host2. Then use --subfolder1 str for restoring
  60. from the folder str, after inverting
  61. host1/host2 user1/user2 values.
  62. Examples:
  63. To restore the whole folder FooArchiv hierarchy into the Foo account:
  64. imapsync ... --user2 Foo --subfolder1 FooArchiv
  65. To restore the whole folder BarArchiv hierarchy into the Bar account:
  66. imapsync ... --user2 Bar --subfolder1 BarArchiv
  67. Read the previous FAQ item "How can I archive different accounts on the same
  68. destination account, each account on a separate folder?"
  69. =======================================================================
  70. Q. How to move emails from one IMAP folder to another, either on the
  71. same IMAP server or on a different one? Example:
  72. How to move all messages older than 1 year, from INBOX to Archive?
  73. R1. Solution:
  74. imapsync ... --minage 365 --folder INBOX --f1f2 INBOX=Archive --delete1 --noexpungeaftereach
  75. Use the option --noexpungeaftereach if speed is a concern.
  76. Use the option --delete1 if you want to move messages, instead of just copy/sync them.
  77. R2. See also file FAQ.Folders_Mapping.txt
  78. https://imapsync.lamiral.info/FAQ.d/FAQ.Archiving.txt
  79. =======================================================================
  80. Q. Can imapsync be used to maintain and restore a local offline copy
  81. of a mailbox, eg for backup purposes, using Mbox or Maildir
  82. format, so that if the server fails, then the mailbox could be
  83. reinstated?
  84. R1. No. Imapsync plays with IMAP servers only.
  85. R2. Imapsync can't but rick-sanders-imap-tools can!
  86. See https://github.com/andrewnimmo/rick-sanders-imap-tools
  87. Back up and restore IMAP accounts with imapdump.pl and dumptoIMAP.pl
  88. It looks like imapdump.pl has options to avoid duplicates and be
  89. in an update mode. There are options -u -U
  90. [-u] Don't dump messages already dumped
  91. [-U] Don't dump message if it already exists in the dump directory
  92. I wonder the difference, I've never used Rick's tools.
  93. Remember that doing backups without trying the restore process
  94. is more dangerous than doing no backups at all. No backups makes
  95. people act in a safer way, well, usually...
  96. R3. Use isync or mbsync
  97. https://isync.sourceforge.io/
  98. R4. Use ImportExportTools for Mozilla Thunderbird by Paolo Kaosmos.
  99. ImportExportTools does not do IMAP as a destination.
  100. R5. There is a free online service (French language) allowing you to do
  101. a Maildir or EML or HTML backup at
  102. https://www.powermail.fr/sauvegarder-une-boite-mail/
  103. Prefer Maildir or EML format if you want to be able to restore the
  104. archive. HTML format will be ok to only view the messages, not to
  105. restore them to an imap server account.
  106. I have never used any of this tools so asking me for support with them
  107. won't go far away.
  108. =======================================================================
  109. Q. How to backup a whole year in a subfolder?
  110. R. To backup the whole year 2018 in a subfolder called ARCHIVE_2018:
  111. imapsync ... --search "SENTSINCE 1-Jan-2018 SENTBEFORE 31-Dec-2018" \
  112. --subfolder2 ARCHIVE_2018
  113. =======================================================================
  114. Q. How to archive a whole year in subfolders but without subsubfolders?
  115. R. Instead of the solution with --subfolder2, use:
  116. imapsync ... --search "SENTSINCE 1-Jan-2018 SENTBEFORE 31-Dec-2018" \
  117. --sep2 _ --regextrans2 's{(.*)}{Archive_$1_2018}'
  118. For each folder "FFFF" in the source account, it will create a destination
  119. folder called "Archive_FFFF_2018", at the top level hierarchy.
  120. =======================================================================
  121. =======================================================================