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

    Zarafa Question: Clean all items from recycle bins that are older than x days

    General Discussion
    3
    8
    3142
    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.
    • IngBueroPlesnik
      IngBueroPlesnik last edited by

      Hello everybody.

      We have a question that I would have asked in the zarafa forum, but I just realizied it is closed and I was redirected to this forum. I hope there is anyone here that can help us.

      We are using groupware/zarafa in version 7.2.4-29 and we would like to automatically delete all items that are older than e.g. 5 days from all recycle bins. Is there a way to do this server-sided?

      Thanks in advance!

      Marcel Schmitz,
      Ing.-Büro Dr. Plesnik GmbH

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

        You can cron-run a server-side python-script for this purpose:
        E.g. delete_olditems.py taken from python-zarafa:

        #!/usr/bin/env python
        
        import zarafa
        from datetime import datetime, timedelta
        import time
        import sys
        
        
        def opt_args():
            parser = zarafa.parser('skpcufm')
            parser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='enable verbose mode')
            return parser.parse_args()
        
        
        def  main():
            options, args = opt_args()
        
            assert args, 'You must specify the amount of days!'
        
            try:
                val = int(args[0])
            except ValueError:
                return sys.exit("Days not specified as a number!")
        
            for user in zarafa.Server(options=options).users(parse=True):
                print 'Running for user: ', user.name
                try:
                    for folder in user.store.folders(parse=True):
                        print 'Folder: ' , folder.name
                        for item in folder.items():
                            if not item.received:
                                continue
                            if item.received < datetime.today() - timedelta(days=int(args[0])):
                                if options.verbose:
                                    print 'Item: ', item.subject, 'Received: ', datetime.today() - item.received
                                else:
                                    print 'Item: ', item.subject
        
                                if options.modify:
                                    folder.delete([item])
                except:
                    continue;
        
        if __name__ == '__main__':
            main()
        

        ++umgfoin

        1 Reply Last reply Reply Quote 1
        • robing
          robing Kopano (Inactive) last edited by

          Hi Marcel,

          This should do the trick:
          https://github.com/zarafagroupware/zarafa-tools/blob/master/mailstore/cleanupscripts/cleanup.py

          python cleanup.py --user <user>  --wastebasket --days <days>
          

          See --help for more options

          And for kopano it should be this script
          https://stash.kopano.io/projects/KSC/repos/core-tools/browse/kopano-cleanup.py

          Regards,

          Robin

          Regards Robin,

          Need support?
          Have a look at https://kopano.com/support/ for options.

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

          IngBueroPlesnik 1 Reply Last reply Reply Quote 1
          • IngBueroPlesnik
            IngBueroPlesnik @robing last edited by

            @robing Thank you for that answer.
            I tried running the script and it does delete some items, but it doesn´t touch the Recycle Bin my Thunderbird shows…

            umgfoin 1 Reply Last reply Reply Quote 0
            • umgfoin
              umgfoin @IngBueroPlesnik last edited by umgfoin

              @IngBueroPlesnik said in Zarafa Question: Clean all items from recycle bins that are older than x days:

              I tried running the script and it does delete some items, but it doesn´t touch the Recycle Bin my Thunderbird shows…

              The script (as above) processes items in the default wastebasket-folder, usually named “Deleted Items” (or “Gelöschte Objekte” with German localization).

              Make sure, thunderbird moves deleted items into this folder and not to another location (e.g. a local folder named "trash"). Depending on your thunderbird-version this might be non-trivial.

              The script I copied above, scan’s for items in the entire folder-tree.
              Anyway, both scripts might be easily modified to fit other needs, too.

              ++umgfoin.

              IngBueroPlesnik 1 Reply Last reply Reply Quote 1
              • IngBueroPlesnik
                IngBueroPlesnik @umgfoin last edited by

                @umgfoin said in Zarafa Question: Clean all items from recycle bins that are older than x days:

                The script (as above) processes items in the default wastebasket-folder, usually named “Deleted Items” (or “Gelöschte Objekte” with German localization).
                Make sure, thunderbird moves deleted items into this folder and not to another location (e.g. a local folder named “trash”). Depending on your thunderbird-version this might be non-trivial.
                The script I copied above, scan’s for items in the entire folder-tree.
                Anyway, both scripts might be easily modified to fit other needs, too.

                Is it hard to modify the script, so that it can clear the “Papierkorb” (Path: imap://example.company.local/Trash).
                Because all our companies thunderbirds are configured to move deleted items to those paths in all of our inboxes.

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

                  Is it hard to modify the script, so that it can clear the “Papierkorb” (Path: imap://example.company.local/Trash).

                  No,

                  1. python delete_olditems.py --help
                  2. python delete_olditems.py --folder="Papierkorb" --modify 5
                    python delete_olditems.py --folder="Trash" --modify 5
                  IngBueroPlesnik 1 Reply Last reply Reply Quote 1
                  • IngBueroPlesnik
                    IngBueroPlesnik @umgfoin last edited by

                    @umgfoin
                    Thank you very much!
                    I´m running the script for the first time right now and I´ll post again when it´s done and I´ve checked the results.

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