FAQ.Emptying.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/cat
  2. $Id: FAQ.Emptying.txt,v 1.14 2022/06/08 11:08:39 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.Emptying.txt
  6. =======================================================================
  7. Imapsync tips about deletions.
  8. =======================================================================
  9. Questions answered in this FAQ are:
  10. Q. How to delete all emails of all folders of an account with imapsync?
  11. Q. How to delete all folders of an account with imapsync?
  12. Q. How to delete some folders of an account with imapsync?
  13. Q. How to revert a sync that went to the wrong account?
  14. Q. How to delete emails older than 90 days with imapsync?
  15. Q. How to delete emails matching a certain criterium with imapsync?
  16. Q. Is there a way to delete the destination folders when the source
  17. folders are no longer there?
  18. Now the questions again with their answers.
  19. =======================================================================
  20. Q. How to delete all emails of all folders of an account with imapsync?
  21. R. Use the same account on both sides with option --delete1
  22. --noexpungeaftereach
  23. Option --noexpungeaftereach is just to speed up the deletions.
  24. Example:
  25. imapsync \
  26. --host1 test.lamiral.info --user1 foo --password1 secret \
  27. --host2 test.lamiral.info --user2 foo --password2 secret \
  28. --delete1 --noexpungeaftereach
  29. =======================================================================
  30. Q. How to delete all folders of an account with imapsync?
  31. R. Use the same account on both sides with the options
  32. --delete1 --noexpungeaftereach --delete1emptyfolders
  33. imapsync ... --delete1 --noexpungeaftereach --delete1emptyfolders
  34. It won't delete the folder INBOX since INBOX is mandatory in imap.
  35. =======================================================================
  36. Q. How to delete some folders of an account with imapsync?
  37. R. Use the same account on both sides with the options
  38. --delete1 --noexpungeaftereach --delete1emptyfolders
  39. like when deleting all folders BUT select only the folders
  40. you want to delete by using options to select folders,
  41. like --folder or --folderrec or --include or --exclude
  42. Example, to delete the folder Blabla
  43. imapsync ... --delete1 --noexpungeaftereach --delete1emptyfolders --folder Blabla
  44. To delete the four folders Kalender Kontakte Aufgaben Notizen:
  45. imapsync ... --include 'Kalender|Kontakte|Aufgaben|Notizen' \
  46. --delete1 --noexpungeaftereach --delete1emptyfolders
  47. I strongly recommend to use --dry first!
  48. To get an overview of how to select folders, see
  49. https://imapsync.lamiral.info/FAQ.d/FAQ.Folders_Selection.txt
  50. =======================================================================
  51. Q. How to revert a sync that went to the wrong account?
  52. R. If all the wrong emails have some common characteristic that is not
  53. shared by the good one, then you can search for them and delete them
  54. using the same account as source and destination. For example, if all
  55. the messages have the same email destination address as
  56. "john_smith@example.com", then you can remove them with the following
  57. command:
  58. imapsync ... --search "TO john_smith@example.com" --delete1
  59. Be very careful with deletions! Since this section deals with something
  60. that was made wrong, you're in good place to make a new one!
  61. There is many possibilities to select messages with different criterium.
  62. See some of them by reading the document
  63. https://imapsync.lamiral.info/FAQ.d/FAQ.Messages_Selection.txt
  64. If the wrongly emails messages synced have no special common
  65. characteristic then take an handkerchief and cry.
  66. =======================================================================
  67. Q. How to delete emails older than 90 days with imapsync?
  68. R. Use the same account on both sides with option --delete1
  69. --noexpungeaftereach --minage 90
  70. Example:
  71. imapsync \
  72. --host1 test.lamiral.info --user1 foo --password1 secret \
  73. --host2 test.lamiral.info --user2 foo --password2 secret \
  74. --delete1 --noexpungeaftereach --minage 90
  75. =======================================================================
  76. Q. How to delete emails matching a certain criterium with imapsync?
  77. R. Use the --search option to select the messages you want to delete
  78. and then use the same account on both sides with the suplementary
  79. options --delete1 --noexpungeaftereach
  80. To select the messages read the document FAQ.Messages_Selection.txt
  81. at https://imapsync.lamiral.info/FAQ.d/FAQ.Messages_Selection.txt
  82. Example:
  83. imapsync \
  84. --host1 test.lamiral.info --user1 foo --password1 secret \
  85. --host2 test.lamiral.info --user2 foo --password2 secret \
  86. --delete1 --noexpungeaftereach --search "SENTBEFORE 31-Dec-2010"
  87. ======================================================================
  88. Q. Is there a way to delete the destination folders when the source
  89. folders are no longer there?
  90. R. Yes, use --delete2folders
  91. --delete2folders : Delete folders in host2 that are not in host1.
  92. For safety, first try it like this, it is safe:
  93. --delete2folders --dry --justfolders --nofoldersizes
  94. and see what folders will be deleted.
  95. --delete2foldersonly reg : Delete only folders matching the regex reg.
  96. Example: --delete2foldersonly "/^Junk$|^INBOX.Junk$/"
  97. This option activates --delete2folders
  98. --delete2foldersbutnot reg : Do not delete folders matching the regex rex.
  99. Example: --delete2foldersbutnot "/Tasks$|Contacts$|Foo$/"
  100. This option activates --delete2folders
  101. =======================================================================
  102. =======================================================================