With gimp fu, I can save the content of one layer (at least, that is how I interprete the definition of gimp_file_save because it takes the parameter
gimp_file_save
I have found out that if you pass None as the drawable argument to gimp_xcf_save(), GIMP (at least version 2.8) will save all layers of the image to the XCF file:
None
drawable
gimp_xcf_save()
pdb.gimp_xcf_save(0, image, None, 'file.xcf', 'file.xcf')