This has been split out from https://github.com/discourse/discourse/pull/28051 so we can use this same code in plugin specs before merging the core PR, adds some helpers for creating local backup temp files and cleaning them up.