Windows has no simple setting to start a backup when you plug in a USB drive. AutoPlay can open a folder or ask what to do, but it no longer runs programs automatically. You can build it yourself with Task Scheduler, triggering a backup script from the event Windows logs when a device connects, or use File History, which resumes when its drive returns. The simplest option is a backup program with a built-in "when the drive is plugged in" trigger.
This guide explains why the plug-in trigger is worth having, how each method works, and how to make it reliable.
Why back up on plug-in?
A drive that stays connected all the time is exposed to the same risks as the PC: ransomware, power surges and theft. A drive you unplug is safer, but a clock-based schedule only works if the drive happens to be connected at 2 a.m. on Sunday. A plug-in trigger fixes that: connect the drive whenever it suits you, the backup runs, and you unplug it again. It is especially useful for:
- Laptops that are only near their backup drive at a desk.
- Rotating two drives between home and somewhere else.
- Keeping an offline copy as protection against ransomware; see how to protect backups from ransomware.
Why AutoPlay cannot do it
Older versions of Windows could run a program listed in an autorun.inf file on the drive. Because malware abused this to spread through USB sticks, Microsoft removed automatic running from USB drives years ago. In Windows 10 and 11, Settings → Bluetooth & devices → AutoPlay lets you choose an action for removable drives, such as Open folder to view files or Configure storage settings (which opens File History in some versions), but not "run my backup script".
Method 1: File History resumes on reconnect
File History is the closest built-in option. When its drive has been disconnected and you plug it back in, File History notices and resumes saving copies on its normal schedule, usually within its next interval (hourly by default).
- Plug in the drive and open Control Panel → File History.
- Click Turn on.
- In Advanced settings, set Save copies of files to a short interval, such as every 10 or 15 minutes, so a backup happens soon after you connect.
Limits: File History only backs up your libraries, Desktop, Contacts and Favorites (plus folders you add to libraries), does not create a system image, and gives no clear signal that the backup is finished and the drive is safe to unplug. If it misbehaves, see File History not working in Windows 11.
Method 2: Task Scheduler and a device event
Task Scheduler can start a task when a specific entry is written to an event log. Windows logs device connections in a log that is off by default, so this takes a few steps.
1. Turn on the device log
- Open Event Viewer.
- Go to Applications and Services Logs → Microsoft → Windows → DriverFrameworks-UserMode → Operational.
- Right-click Operational and choose Enable Log.
- Plug in your backup drive, then refresh the log and note the event ID that appears on connection. It is commonly 2003 or 2100, but check on your own PC.
2. Write a backup script that checks for the right drive
The event fires for any USB device, so the script should only run when your backup drive is present. Give the drive a fixed letter, such as R:, in Disk Management, and put a marker file on it, such as R:\backup-drive.txt. Then create usb-backup.bat:
if not exist R:\backup-drive.txt exit /b
timeout /t 20
robocopy "C:\Users\You\Documents" "R:\Backup\Documents" /E /R:2 /W:5 /LOG:R:\Backup\log.txt
The pause gives Windows time to mount the drive.
3. Create the task
- In Task Scheduler, choose Create Task.
- On Triggers, click New, choose On an event, select the log Microsoft-Windows-DriverFrameworks-UserMode/Operational, and enter the event ID you noted.
- On Actions, start your batch file.
- On Settings, set If the task is already running to Do not start a new instance, because one plug-in can log several events.
This method is fiddly. Event IDs and logging can differ between Windows versions and devices, and a Robocopy copy is not a versioned backup: it overwrites yesterday's copy, including with damaged or encrypted files. Test it carefully and check the log file regularly.
Method 3: a backup program with a plug-in trigger
A backup tool with a built-in device trigger does all of this for you. Rocket Backups can run any backup job when you plug in your backup drive, alongside its hourly, daily, weekly and monthly schedules and its log-in, shut-down and idle triggers. The job can be a system image, whole drives or chosen folders, it runs incrementally so only changes are copied, and it keeps version history by the rules you set.
A good setup for a laptop:
- Create a job for your system drive image plus your work folders.
- Choose the external drive as the destination and turn on encryption.
- Set the trigger to run when the drive is plugged in.
- Plug in the drive once or twice a week, wait for the tray icon to show the backup has finished and been verified, and then unplug.
If you forget for a while, Rocket Backups can email you if a job fails or the backup drive is missing, so the plug-in approach does not quietly turn into no backup at all.
Comparing the methods
| File History | Task Scheduler event | Backup program trigger | |
|---|---|---|---|
| Setup effort | Low | High | Low |
| Starts soon after plug-in | At next interval | Yes | Yes |
| System image | No | No (unless scripting wbadmin) | Yes |
| Versions | Yes | No | Yes |
| Tells you when it is done | No | No | Yes |
Tips for plug-in backups
- Fix the drive letter in Disk Management so scripts and jobs always find it.
- Eject before unplugging. Use Safely Remove Hardware or right-click the drive in File Explorer and choose Eject.
- Use two drives and keep one elsewhere, swapping weekly.
- Set a reminder to plug in the drive, such as every Friday afternoon.
- Test a restore from the drive every few months; see how to verify a backup works.
Frequently asked questions
Can AutoPlay run a backup when I plug in a drive?
No. Modern Windows AutoPlay can open a folder or offer options, but it no longer runs programs from a drive automatically for security reasons.
Why does my drive get a different letter each time?
Windows assigns the next free letter. Give the backup drive a fixed letter late in the alphabet in Disk Management so jobs can find it.
Is it safe to unplug the drive straight after the backup?
Wait until the backup has finished and been verified, then use Safely Remove Hardware or eject it from File Explorer.
