def restore(input): if not os.path.exists(input): print "Warning! %s is not existed." % input return if not os.path.isdir(input): print "Loading %s" % input file = BackupFile(input) result = file.load() model_class = file.get_model_class() print "Uploading data to %s..." % model_class.kind() app.upload_model(model_class,result) else: regexp = re.compile("^.*\.json$") for file in os.listdir(input): if regexp.match(file): restore(input +"/" +file)
model_classes = [] for entry in GAE_BACKUP_MODELS: __import__(entry[0]) for model in entry[1]: try: model_classes.append( db._kind_map[model] ) except KeyError , e: print "%s not found." % model print "Available models" print [key for key in db._kind_map] if options.output: output_path = options.output else: output_path = timestamp if not os.path.exists(output_path): os.mkdir(output_path) for model_class in model_classes: filename = output_path + "/%s.json" % model_class.kind() print "Saving changes to %s" % filename result = app.download_model(model_class) file = BackupFile(filename = filename, model_class = model_class) file.save(result)