Navigation

    Kopano
    • Register
    • Login
    • Search
    • Categories
    • Get Official Kopano Support
    • Recent
    Statement regarding the closure of the Kopano community forum and the end of the community edition

    kopano-cleanup.py script help

    Kopano Groupware Core
    5
    11
    2749
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fbartels
      fbartels Kopano @teka74 last edited by

      Hello @teka74 ,

      I guess you are referring to https://kb.kopano.io/display/WIKI/Kopano+cleanup ?

      In the way the script is now you would need to get a user list before and call it per user (there is no “all” switch for the username). Listing users is quite simple, you can find an example at https://stash.kopano.io/projects/KSC/repos/lab-scripts/browse/python-kopano/list-users.py. You can find an example script which has the possibility to run for all users on a system at https://stash.kopano.io/projects/KSC/repos/webapp-tools/browse/set_webapp_default_signature.py

      What more description would you be looking for, for said Knowledgebase article?

      Regards Felix

      Resources:
      https://kopano.com/blog/how-to-get-kopano/
      https://documentation.kopano.io/
      https://kb.kopano.io/

      Support overview:
      https://kopano.com/support/

      1 Reply Last reply Reply Quote 0
      • teka74
        teka74 last edited by

        @fbartels said in kopano-cleanup.py script help:

        Hello @teka74 ,

        I guess you are referring to https://kb.kopano.io/display/WIKI/Kopano+cleanup ?

        In the way the script is now you would need to get a user list before and call it per user (there is no “all” switch for the username). Listing users is quite simple, you can find an example at https://stash.kopano.io/projects/KSC/repos/lab-scripts/browse/python-kopano/list-users.py. You can find an example script which has the possibility to run for all users on a system at https://stash.kopano.io/projects/KSC/repos/webapp-tools/browse/set_webapp_default_signature.py

        What more description would you be looking for, for said Knowledgebase article?

        Yes, it is this script, I will look at the other scripts, and try to get working cleanup script. I will post here in a few days.

        Thanks, and a nice weekend

        Thomas

        heiko 1 Reply Last reply Reply Quote 0
        • teka74
          teka74 last edited by

          Hello Kopanos!

          I got the cleanup script working, and it worked for several months. After upgrading kopano core to newest version, the cleanup script gives some errors. How do i fix it ?

          I call the script daily via crontab, and error occurs only at first user in list:

          (mail adress made anonymous)

          Running script for 'txxxx@wahlshausen.de'
          Traceback (most recent call last):
            File "/usr/share/kopano/kopano-cleanup.py", line 98, in <module>
              main()
            File "/usr/share/kopano/kopano-cleanup.py", line 82, in main
              count = deleteitems(options, folder, daysbeforedeleted, pbar)
            File "/usr/share/kopano/kopano-cleanup.py", line 51, in deleteitems
              if not item.prop(PR_LAST_MODIFICATION_TIME).value and options.force:
            File "/usr/lib/python2.7/dist-packages/kopano/properties.py", line 39, in prop
              return _prop.prop(self, self.mapiobj, proptag, create=create,
            File "/usr/lib/python2.7/dist-packages/kopano/item.py", line 201, in mapiobj
              self.mapiobj = _utils.openentry_raw(self.store.mapiobj, self._entryid, self._content_flag)
            File "/usr/lib/python2.7/dist-packages/kopano/utils.py", line 74, in openentry_raw
              return _openentry_helper(mapistore, entryid, flags | MAPI_MODIFY)
            File "/usr/lib/python2.7/dist-packages/kopano/utils.py", line 68, in _openentry_helper
              return mapistore.OpenEntry(entryid, IID_IECMessageRaw, flags)
            File "/usr/lib/python2.7/dist-packages/MAPICore.py", line 965, in OpenEntry
              return _MAPICore.IMsgStore_OpenEntry(self, cbEntryID, lpInterface, ulFlags)
          TypeError: in method 'IMsgStore_OpenEntry', argument 2 of type 'ULONG'
          Running script for 'axxxx@wahlshausen.de'
          Deleted 0 item(s) for user 'axxxx@wahlshausen.de' in folder 'Gelöschte Objekte'
          Deleted 0 item(s) for user 'axxxx@wahlshausen.de' in folder 'Junk E-Mail'
          Running script for 'exxxx@wahlshausen.de'
          Deleted 15 item(s) for user 'exxxx@wahlshausen.de' in folder 'Gelöschte Objekte'
          Deleted 3 item(s) for user 'exxxx@wahlshausen.de' in folder 'Junk E-Mail'
          
          fbartels 1 Reply Last reply Reply Quote 0
          • fbartels
            fbartels Kopano @teka74 last edited by

            Hi @teka74 ,

            some more information would be helpful.

            • which (exact) version of kopano core are you running now?
            • which (exact) version of kopano core were you running before?
            • which script are you running? if you made modifications to it then having the exact script to reproduce the error would be helpful.

            Regards Felix

            Resources:
            https://kopano.com/blog/how-to-get-kopano/
            https://documentation.kopano.io/
            https://kb.kopano.io/

            Support overview:
            https://kopano.com/support/

            1 Reply Last reply Reply Quote 0
            • teka74
              teka74 last edited by

              I’ve upgraded from an early 8.4.20 to the new 8.4.90

              And the script i’ve been running every night is from here:

              https://stash.kopano.io/projects/KSC/repos/core-tools/browse/kopano-cleanup.py

              1 Reply Last reply Reply Quote 0
              • teka74
                teka74 last edited by

                I thinki it’s solved !

                I found this in another thread:

                https://forum.kopano.io/topic/891/solved-message-cannot-be-opened-problem-with-core-8-4-90-1296_0-157-ubuntu_16-04-amd64/7

                followed the instructions, and now the cleanup-script is running as usual without errors

                Thomas

                1 Reply Last reply Reply Quote 0
                • MyKey0815
                  MyKey0815 last edited by

                  The script is working fine for me. But how can i enhance it, that i can delete “Posteingang” and “Gesendete Objekte” too?

                  I have some mailboxes with newsletters and very old stuff - so it will be much helpfull for me

                  Michael

                  1 Reply Last reply Reply Quote 0
                  • MyKey0815
                    MyKey0815 last edited by

                    I have made following additions in thescript:

                    parser.add_option("–inbox", dest=“inbox”, action=“store_true”, help=“Run cleanup script for the inbox folder”)
                    parser.add_option("–sent", dest=“sent”, action=“store_true”, help=“Run cleanup script for the sent folder”)

                    and

                    if options.inbox:
                        folder = user.store.inbox
                        if options.progressbar:
                            pbar = progressbar(folder, daysbeforedeleted)
                        count = deleteitems(options, folder, daysbeforedeleted, pbar)
                        if options.progressbar:
                            pbar.finish()
                        print 'Deleted %s item(s) for user \'%s\' in folder \'%s\'' % (count, user.name, folder.name)
                    
                    if options.sent:
                        folder = user.store.sentmail
                        if options.progressbar:
                            pbar = progressbar(folder, daysbeforedeleted)
                        count = deleteitems(options, folder, daysbeforedeleted, pbar)
                        if options.progressbar:
                            pbar.finish()
                        print 'Deleted %s item(s) for user \'%s\' in folder \'%s\'' % (count, user.name, folder.name)
                    

                    Now I have the option switches --inbox and --sent for cleanup this folders too

                    1 Reply Last reply Reply Quote 0
                    • mmain
                      mmain last edited by

                      Is it possible to distinguish read / unread emails in the inbox deletion process?

                      1 Reply Last reply Reply Quote 0
                      • heiko
                        heiko @teka74 last edited by

                        @teka74
                        Hello Thomas,

                        would you please publish how you had changed the kopano-cleanup.py to work for all users?

                        I found the other script which print all users of my kopano but i don‘t know to combine both because i don’t know anything about python.

                        Regards
                        Heiko

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post