Windows 11 is oddly quiet about local backups. The new Windows Backup app only backs up to OneDrive, and the old System Image tool has been deprecated for years. If you have a NAS at home, though, you can still build a reliable, free backup with two tools that ship with every copy of Windows: File History for versioned copies of your personal files, and robocopy for scheduled copies of any other folder.
This guide uses a Synology NAS on DSM 7, but any NAS or Linux server with an SMB share works the same way. It was written against Windows 11 24H2.
The plan
- A dedicated NAS account that can only write to one backup share.
- File History saves hourly versions of Documents, Desktop, Pictures and the other libraries.
- A robocopy script mirrors folders File History doesn't cover, such as
C:\Projects, and runs every night from Task Scheduler. - Snapshots on the NAS keep older copies, so ransomware on the PC can't wipe out your history.
- A restore test, because a backup you haven't restored from is only a hope.
Step 1: prepare the NAS
In DSM, create a shared folder called Backups. If the volume is Btrfs, leave the recycle bin on and plan to add snapshots (Step 6).
Then create a user just for backups, for example winbackup:
- Control Panel > User & Group > Create. Give it a long random password and save it in your password manager.
- On the permissions page, give it Read/Write on
Backupsand No access on every other share. - On the applications page, deny everything except SMB. It doesn't need DSM, File Station or SSH.
Check SMB settings under Control Panel > File Services > SMB > Advanced Settings: set the minimum protocol to SMB2 and the maximum to SMB3. Never enable SMB1.
Why a separate account? If your Windows login were the one writing backups, and with access to every share on the NAS, then any malware running as you could encrypt the whole NAS too. A narrowly scoped account limits the damage.
Step 2: save the credentials in Windows
Open Terminal (PowerShell) as your normal user and store the NAS login in Windows Credential Manager:
cmdkey /add:nas.local /user:nas.local\winbackup /pass
Leaving /pass without a value makes Windows prompt for the password, so it isn't saved in your shell history. Replace nas.local with your NAS's name or IP address. Using a fixed IP (a DHCP reservation on your router) avoids name-resolution problems later.
Test the connection:
Test-Path \\nas.local\Backups New-Item -ItemType Directory \\nas.local\Backups\$env:COMPUTERNAME -Force
True and a new folder named after your PC mean the share and credentials work.
Step 3: turn on File History
Windows 11 removed File History from the Settings app, but it still works from Control Panel:
- Press Win+R, type
control /name Microsoft.FileHistoryand press Enter. - Click Select drive > Add network location, then enter
\\nas.local\Backups\YOURPC. - Click Turn on.
Then open Advanced settings and pick:
- Save copies of files: every hour is the default and fine for most people. Every 15 minutes suits work you can't redo.
- Keep saved versions: the default is *forever*, which slowly fills the share. *Until space is needed* or *1 year* is more practical.
File History backs up your user libraries (Documents, Music, Pictures, Videos), the Desktop, Contacts and Favorites. In Windows 11 there's no button to add other folders. You can add a folder to a library instead (in File Explorer, turn on View > Show > Libraries, right-click a library and choose Properties > Add), but for folders outside your user profile, robocopy is cleaner.
To restore, open the same Control Panel page and click Restore personal files. You can browse by date and restore any older version of a file.
Step 4: a robocopy job for everything else
Robocopy copies only files that changed, survives network drops and logs everything. Save this as C:\Scripts\nas-backup.ps1:
$dest = "\\nas.local\Backups\$env:COMPUTERNAME\robocopy"
$log = "C:\Scripts\logs\nas-backup-$(Get-Date -Format yyyy-MM-dd).log"
New-Item -ItemType Directory -Force -Path (Split-Path $log) | Out-Null
$jobs = @{
"C:\Projects" = "$dest\Projects"
"$env:USERPROFILE\.ssh" = "$dest\ssh"
"D:\Photos" = "$dest\Photos"
}
$failed = $false
foreach ($src in $jobs.Keys) {
if (-not (Test-Path $src)) { continue }
robocopy $src $jobs[$src] /MIR /FFT /XJ /R:2 /W:10 /MT:8 /NP /NDL /LOG+:$log
if ($LASTEXITCODE -ge 8) { $failed = $true }
}
if ($failed) { exit 1 } else { exit 0 }
What the switches do:
/MIRmakes the destination an exact mirror, including deleting files you deleted. That's why the NAS snapshots in Step 6 matter. If you'd rather never delete anything on the NAS, use/Einstead./FFTallows two-second timestamp differences. Without it, robocopy sometimes thinks every file changed on Samba-based NAS shares and copies everything every time./XJskips junction points. Your user profile contains junctions that otherwise cause endless loops./R:2 /W:10retries a locked file twice, ten seconds apart, instead of the default million retries./MT:8copies eight files at once, which helps with folders of many small files.
Robocopy's exit codes are unusual: 0 to 7 mean success (for example 1 means "files were copied"), and 8 or higher means something failed. The script turns that into a normal 0 or 1 so Task Scheduler reports it properly.
Run it once by hand and read the log:
powershell -NoProfile -ExecutionPolicy Bypass -File C:\Scripts\nas-backup.ps1 Get-Content C:\Scripts\logs\*.log -Tail 20
The summary table at the end of each section shows how many files were copied, skipped and failed.
Step 5: schedule it
Create a nightly task that runs as you, so it can use the saved NAS credentials:
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\nas-backup.ps1" $trigger = New-ScheduledTaskTrigger -Daily -At 9pm $set = New-ScheduledTaskSettingsSet -StartWhenAvailable -RunOnlyIfNetworkAvailable Register-ScheduledTask -TaskName "NAS backup" -Action $action -Trigger $trigger -Settings $set
-StartWhenAvailable means a missed run (because the PC was off) happens the next time it's on. Check the Last Run Result in Task Scheduler the next morning: 0x0 is success and 0x1 means the script saw a robocopy failure.
Step 6: protect the backups with snapshots
A mirror isn't a history. If ransomware encrypts C:\Projects, the next robocopy run faithfully copies the encrypted files to the NAS. Snapshots stop that from being a disaster.
On a Synology with a Btrfs volume, install Snapshot Replication from Package Center, select the Backups share and set a schedule, for example a snapshot every day kept for 30 days. Because the winbackup account can't delete snapshots, a compromised PC can't erase them either. On other NAS systems, look for "snapshots" or "versioning" on the share. My Btrfs vs ZFS guide explains why copy-on-write snapshots are so cheap.
For the important files, add a copy that isn't in your house, such as Synology Hyper Backup to a cloud bucket or a USB drive you keep elsewhere. That's the 3-2-1 rule: three copies, on two kinds of storage, one off-site.
Step 7: test a restore
Pick a file you changed recently and restore it both ways:
- File History: Control Panel > File History > Restore personal files, go back a few versions and restore to a different folder.
- Robocopy plus snapshot: in DSM, open the
Backupsshare in File Station, or use Snapshot Replication's browse option, and copy yesterday's version back.
Put a reminder in your calendar to do this every few months.
Troubleshooting
- File History says the drive is disconnected. Usually a sleeping NAS or a changed IP. Use a fixed IP and check that
Test-Pathworks. - "Access is denied" in robocopy. The stored credential is wrong or the share permission isn't Read/Write. Run
cmdkey /listto check what's saved. - Robocopy copies everything every night. Add
/FFTand check the PC and NAS clocks are both correct. - The task runs but nothing is copied. Tasks set to "Run whether user is logged on or not" may not see your saved credentials. Run the task as your user, logged on, or store the credential for the account the task runs as.
Summary
File History handles versioned copies of your personal files, robocopy covers the rest, Task Scheduler runs it every night, and NAS snapshots make sure a bad day on the PC can't destroy your history. Everything here is built into Windows and DSM, so it costs nothing. To reach the NAS from outside the house as well, see Tailscale vs WireGuard for a home NAS.
Comments (0)
No comments yet. Be the first to leave one!
Leave a Comment