Just some thoughts...
Some (many/most/all?) virtual hosting systems allow you to take snapshots at periodic intervals, and provide the capability to roll back to one of them as required.
Otherwise, you would have to rely on system backups. If the domain within which you are working is limited to a small-ish set of files, then periodic backups can be more frequent.
Software developers use revision control systems that allow you to recover selected versions of files. Those require deliberate committal to the revision control system at appropriate intervals, and are best for text files.