Manual:ExportSites.php

Details
exportSites.php maintenance script exports site definitions from the sites table into XML file.

Common error
It comes when the user running the script does not have permission to write the file.
 * Failed to open $file for writing.

Check user's permission. If you are root user then you can run script with sudo.