Unified code for generation of File object
Added support for backup of cache (needs testing)