AutoRecover retention policy and cleanup timing in Visual Studio 2022
0 reputation · 31 Jan 2024, 02:50 UTC
0 reputation · 31 Jan 2024, 02:50 UTC
The goal is to understand and configure how long AutoRecover files are kept and when they are purged, so that recovery data can be reliably integrated into a backup and verification workflow.
AutoRecover is enabled by default and stores snapshots every 5 minutes, with a 7‑day retention period. The snapshots are written to a machine‑specific directory (%LOCALAPPDATA%\Microsoft\VisualStudio\\AutoRecover) and are not part of the VCS or server‑side backup. The exact trigger for cleanup—whether it occurs on startup, shutdown, or via a background job—is not clearly documented, and there is no exposed API to adjust the retention period beyond the UI setting.
Because the AutoRecover directory is local, restoring a solution on a different machine or after a profile reset may leave the IDE unable to recover unsaved work, creating a gap in the backup strategy. Verification of recovered data currently requires manual diffing against the last committed state.
31275 reputation · 31 Jan 2024, 06:02 UTC
Confirmed behavior: Visual Studio 2022 removes AutoRecover snapshots that are older than the retention period set in the IDE options (default 7 days). The purge happens in two places:
The exact interval of the background scan is not documented, but observations show it runs roughly every few hours; under heavy CPU load the scan may be delayed, allowing aged files to persist longer than the nominal retention.
There is no supported API or command‑line switch. The retention period and save frequency are stored per‑user in the registry:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\17.0_Config\AutoRecover AutoRecoverDays (DWORD) – days to keep snapshots AutoRecoverInterval (DWORD) – minutes between saves
- Close all instances of Visual Studio 2022.
- Open RegEdit and navigate to the key above.
- Modify
AutoRecoverDaysto the desired value (e.g., 3 for three days).- Optionally adjust
AutoRecoverIntervalif you want a different snapshot frequency.- Save the changes and restart Visual Studio.
After the restart, the next startup scan (or the next background run) will remove snapshots older than the new period. If you need an immediate purge without waiting for the background service, simply restarting VS triggers the startup scan.
Verification and limitations
Visual Studio does not automatically compare recovered files with the last committed state in source control. Verification must be done manually (e.g., using a diff tool) or via an external script that compares the AutoRecover folder with the latest commit.
Because AutoRecover data is stored locally and is not synchronized with source control, moving a solution to another machine or resetting the user profile will not preserve recovery snapshots, making AutoRecover unsuitable as a primary backup mechanism.
Missing diagnostic detail
If you observe that aged snapshots are not being removed even after the expected time, please confirm whether Visual Studio was running continuously during that interval (the background service may be delayed under load). Knowing whether the IDE was open or closed will determine if you need to rely on the startup scan or investigate the background service timing.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.