You should be able to create these via import. See the category bootstrap. Creating groups via import should be similar to creating user by import. I think the RM module does this.
I have fixed my issue regarding groups. Unfortunately, I am not able to import categories. I have created the module-context.xml file to import users, groups, spaces,…. and categories.
The xml description of the bean (refering to spacesBootstrap importer) which import the categories requires a path key prop. I have no idea which path is it for categories to be imported.