file: Use the database to save files as a failsafe

If unable to save to primary backend, use the database as a failsafe