How to save an animation using python
This works, you can even name the file during the save:

fp = "/home/username/SomeFolder/doubles.blend"  # or whatever you use.
bpy.ops.wm.save_as_mainfile(filepath=fp)