Option to ignore a list of folders?
Closed this issue · 3 comments
C-Duv commented
Some IMAP servers provides non-e-mails as mailboxes. For instance Exchange has:
- Calendar
- Contacts
- Tasks
- RSS Feeds
- Journal
- Also: Sync Issues
When backuping such mailboxes with imapbackup it can fails, or even if it does not, maybe you don't want to backup theses folders.
There is an option to pass folder(s) to backup, but none for the one to ignore
If desired I can provide a small PR introducing the --ignored-folders
option with the following changes:
@@ -675,12 +675,16 @@ def main():
server = connect_and_login(config)
names = get_names(server, config['compress'], config['thunderbird'],
config['nospinner'])
+ ignored_dirs = []
if config.get('folders'):
dirs = map(lambda x: x.strip(), config.get('folders').split(','))
if config['thunderbird']:
dirs = [i.replace("Inbox", "INBOX", 1) if i.startswith("Inbox") else i
for i in dirs]
names = filter(lambda x: x[0] in dirs, names)
+ elif config.get('ignored-folders'):
+ # Use "--ignored-folders" option's list only if "--folders" option was not set
+ ignored_dirs = map(lambda x: x.strip(), config.get('ignored-folders').split(','))
# for n, name in enumerate(names): # *DEBUG
# print n, name # *DEBUG
@@ -690,6 +694,11 @@ def main():
for name_pair in names:
try:
foldername, filename = name_pair
+
+ # Skip ignored directory
+ if foldername in ignored_dirs:
+ continue
+
fol_messages = scan_folder(
server, foldername, config['nospinner'])
fil_messages = scan_file(filename, config['compress'],
rcarmo commented
I'd be perfectly OK with that. I originally build the script for targeted backups, so... glad to have that tested and added.