Keep an independent copy
A connected drive or synchronised folder can be affected when your computer rewrites files. Keep one recent offline copy and a separately stored encrypted copy. Unplug your external backup drive after verifying the backup.
Check older copies
Test a backup from before the problem. Use a device known to be clean when you restore. Start by opening a few recovered documents and photos in a new folder to check them without replacing any backups.
Recover in stages
Leave the affected device disconnected while you investigate with IT support or a qualified technician. Restore essential files first and check them before restoring the rest. Cloud version history may retain fewer file versions than your separate backups.