How to use kolab undelete-mailbox CLI command



  • I'm trying to figure out how the kolab undelete-mailbox command actually works. Unfortunately the documentation isn't really covering it and Google does not help either.
    https://docs.kolab.org/administrator-guide/using-the-kolab-command-line.html#undelete-mailbox

    Can anyone help me out here?



  • It undeletes folders that have not yet been removed from disk (there is a configurable grace period between when the user deletes something and it is actually removed; be default this is several weeks)

    from the documentation in the sources:

        """
            Login to the actual backend server, then "undelete" the mailfolder.
    
            'mailfolder' may be a string representing either of the following
            two options;
    
            - the fully qualified pathof the deleted folder in its current
              location, such as, for a deleted INBOX folder originally known as
              "user/userid[@domain]";
    
                "DELETED/user/userid/hex[@domain]"
    
            - the original folder name, such as;
    
                "user/userid[@domain]"
    
            'to_mailfolder' may be the target folder to "undelete" the deleted
            folder to. If not specified, the original folder name is used.
        """


  • @aseigo thanks!

    I tried the following

    user@kolab1:~$ sudo kolab undelete-mailbox DELETED/user/username/Calendar/ Personal\ Calendar/57503493@domain.tld
    

    I get no error back but the "mailbox" is not restored and remains under DELETED. Could this be because it's a calendar and not actually a mailbox?

    according to this a target is not needed

            'to_mailfolder' may be the target folder to "undelete" the deleted
            folder to. If not specified, the original folder name is used.
    

    Am I missing on something?



  • @FreeMinded said in How to use kolab undelete-mailbox CLI command:

    sudo kolab undelete-mailbox DELETED/user/username/Calendar/ Personal\ Calendar/57503493@domain.tld

    Was that the exact command you used? .. or did you retype it for the comment?

    ... because I see a space between "Calendar/" and Peronal .. and your user's login is "username"? .. and it's a multi-domain setup with the target domain being "domain.tld"?

    I'm going to assume this was not the actual command you used .. so -> did you confirm that the deleted folder exists on disk with the name you provided it?

    Could this be because it's a calendar and not actually a mailbox?

    No, this doesn't matter.



  • @aseigo said in How to use kolab undelete-mailbox CLI command:

    Was that the exact command you used? .. or did you retype it for the comment?

    ... because I see a space between "Calendar/" and Peronal .. and your user's login is "username"? .. and it's a multi-domain setup with the target domain being "domain.tld"?

    I'm going to assume this was not the actual command you used .. so -> did you confirm that the deleted folder exists on disk with the name you provided it?

    Yes, I removed personal information and replaced it by generic values such as username, domain, etc. Sorry, I should have mentioned that. And yes, it's a multi-domain setup. The space between ...Calender/ Personal... came from formatting the post.

    I run the command against the output of the list mailboxes command
    kolab lm
    So I guess the folder should be there. If I enter an invalid mailbox the I get the error below.

    Traceback (most recent call last):
      File "/sbin/kolab", line 39, in <module>
        kolab = Cli()
      File "/usr/lib/python2.7/site-packages/pykolab/cli/__init__.py", line 73, in __init__
        commands.execute('_'.join(to_execute))
      File "/usr/lib/python2.7/site-packages/pykolab/cli/commands.py", line 138, in execute
        commands[cmd_name]['function'](conf.cli_args, kw)
      File "/usr/lib/python2.7/site-packages/pykolab/cli/cmd_undelete_mailbox.py", line 57, in execute
        imap.undelete_mailfolder(undelete_folder, target_folder)
      File "/usr/lib/python2.7/site-packages/pykolab/imap/__init__.py", line 1184, in undelete_mailfolder
        self.imap.undelete_mailfolder(*args, **kw)
      File "/usr/lib/python2.7/site-packages/pykolab/imap/cyrus.py", line 416, in undelete_mailfolder
        undelete_folders = self._find_deleted_folder(mailfolder)
      File "/usr/lib/python2.7/site-packages/pykolab/imap/cyrus.py", line 586, in _find_deleted_folder
        'mailfolder': self.separator.join(mbox['path_parts']),
    TypeError: 'NoneType' object has no attribute '__getitem__'
    

Log in to reply