Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

Script is able to backup and restore your WebApp settings. 
Backup file will be saved as a json file in the following format 'username.json'
It will overwrite a previous version if exist in the same directory  Expand source
 master  KSC/webapp-tools
#!/usr/bin/env python
#encoding: utf-8

from MAPI import *
from MAPI.Util import *
import sys
    import kopano
except ImportError:
    import zarafa as kopano
    import json
except ImportError:
    import simplejson as json

def opt_args():
    parser = kopano.parser('skpcfm')
    parser.add_option("--user", dest="user", action="store", help="Run script for user")
    parser.add_option("--backup", dest="backup", action="store_true", help="Backup webapp setting ")
    parser.add_option("--restore", dest="restore", action="store_true", help="Restore webapp settings")

    return parser.parse_args()

def main():
    options, args = opt_args()

    if not options.user or (not options.backup and not options.restore):
        print 'Please use:\n %s --user <username> (--backup or --restore)  ' % (sys.argv[0])

    user = kopano.Server(options).user(options.user)
    if options.backup:
        webapp = json.loads(
        f = open('%s.json' %,'w')

        f.write(json.dumps(webapp, sort_keys=True,
                     indent=4, separators=(',', ': ')))
    if options.restore:
        with open('%s.json' % as data_file:
            data = json.load(data_file)

        print data
if __name__ == "__main__":



python --user user  --backup
python --user user  --restore

  • No labels