How to set up and manage automatic backups to a USB drive that only connects on a schedule to protect against ransomware
Summary
This guide helps you troubleshoot and resolve: How to set up and manage automatic backups to a USB drive that only connects on a schedule to protect against ransomware. Follow the steps below to fix the issue.
Common Causes
Keeping backups offline is one of the strongest defences against ransomware. If your backup drive sits plugged in permanently, malicious software on your network can encrypt or delete those backups just as easily as your live data. By only connecting your USB drive during a short, scheduled backup window, you dramatically reduce the window of opportunity for ransomware to reach it.
This guide walks you through setting up a scheduled backup that runs while the drive is connected, then safely disconnects the drive when the job is finished. The approach works on both Windows and macOS and does not require any paid software.
How the Scheduled Offline Backup Approach Works
The concept is straightforward:
- You set a recurring backup window (for example, every weekday at 11pm).
- At the start of that window, you connect the USB drive.
- The backup software runs automatically.
- When the backup finishes, the software ejects the drive and you unplug it.
- The drive spends the rest of the day offline, invisible to ransomware.
What You Will Need
- A USB drive or external HDD with enough capacity for your data. We recommend a drive dedicated solely to backups.
- A computer running Windows 10/11 or macOS 12 or later.
- Built-in backup tools (File History on Windows, Time Machine on macOS) or a third-party tool such as Veeam Agent Free, Duplicati, or Arq.
- A small calendar reminder or scheduled task to physically plug the drive in at the right time.
Quick Fix Steps
- Prepare and label your USB backup drive.
- Configure your backup software to run on a schedule.
- Set the software to eject the drive when finished.
- Create a recurring reminder to plug the drive in before the backup window.
- Test the full cycle end-to-end.
Detailed Instructions
Step 1: Prepare the Backup Drive
- Connect the USB drive to your computer.
- Open Disk Management on Windows (right-click the Start button and choose Disk Management) or Disk Utility on macOS (Applications > Utilities > Disk Utility).
- Format the drive as
NTFS(Windows) orAPFS(macOS) and give it a clear label such asOFFLINE-BACKUP. - Eject the drive safely.
Step 2: Configure File History on Windows
- Connect the USB drive.
- Open Settings > Update & Security > Backup (Windows 10) or Settings > System > Storage > Advanced storage settings > Backup options (Windows 11).
- Click Add a drive and select your USB drive.
- Click More options to set the backup frequency (for example, Every 1 hour) and how long to keep backups.
- Under Back up these folders, add or remove folders to match what you need to protect.
- Click Back up now to perform an initial backup.
Step 3: Configure Time Machine on macOS
- Connect the USB drive.
- Open System Settings > General > Time Machine.
- Click Add Backup Disk and select your USB drive.
- Choose Set Up Disk and decide whether to encrypt the backups (recommended).
- Time Machine will begin its first backup automatically. Subsequent backups run hourly when the drive is connected.
Step 4: Use a Third-Party Backup Tool (Optional but Recommended)
Built-in tools are good, but dedicated backup software gives you more control over scheduling and post-backup actions. Tools we commonly recommend include:
- Veeam Agent for Windows (Free) — supports scheduled jobs, retention policies, and post-backup scripts.
- Duplicati — cross-platform, supports encrypted backups to local USB.
- Arq Backup — paid, but excellent for macOS with strong encryption.
Whichever tool you choose, configure it to:
- Run only during your defined backup window.
- Verify the backup after writing.
- Execute a post-backup command to eject the drive.
Step 5: Automate Ejection of the USB Drive
On Windows using a Scheduled Task
- Open Task Scheduler (search for it from the Start menu).
- Click Create Task (not Create Basic Task) for more control.
- Give it a name such as
Eject Backup Drive. - On the Triggers tab, create a new trigger that runs Daily at the time you want the backup to finish (for example, 11:30pm).
- On the Actions tab, choose Start a program and enter:
powershell.exe - In the Add arguments field, enter:
-Command "(New-Object -COMObject Shell.Application).NameSpace(17).ParseName('E:').InvokeVerb('Eject')" - Replace
E:with the actual drive letter of your USB drive. - Click OK and test the task by right-clicking it and choosing Run.
On macOS using a launchd script
- Open Terminal (Applications > Utilities > Terminal).
- Create a script file with:
nano ~/eject-backup.sh - Add the following line, replacing
OFFLINE-BACKUPwith your drive label:diskutil unmount /Volumes/OFFLINE-BACKUP
- Save with
Ctrl+O, then exit withCtrl+X. - Make the script executable:
chmod +x ~/eject-backup.sh - Create a launchd plist file to schedule the script. Open Terminal and run:
nano ~/Library/LaunchAgents/com.local.eject-backup.plist - Add the following content, replacing
yourusernamewith your actual macOS username:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.local.eject-backup</string> <key>ProgramArguments</key> <array> <string>/Users/yourusername/eject-backup.sh</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>23</integer> <key>Minute</key> <integer>30</integer> </dict> </dict> </plist> - Save with
Ctrl+O, then exit withCtrl+X. - Load the launchd job with:
launchctl load ~/Library/LaunchAgents/com.local.eject-backup.plist
Step 6: Create a Reminder to Plug the Drive In
- Open your calendar app (Outlook, Google Calendar, or Apple Calendar).
- Create a recurring event titled Plug in backup drive.
- Set it to repeat on the days you want backups (for example, weekdays).
- Set the reminder to alert you 5 minutes before the backup window starts.
Step 7: Test the Full Cycle
- Plug in the drive at the scheduled time.
- Wait for the backup to run and complete.
- Confirm the drive was ejected automatically.
- Reconnect the drive and verify the backup files are present and readable.
- Test restoring a single file from the backup to confirm it works correctly.
- Check your backup software logs to confirm no errors occurred.
Troubleshooting
- Backup fails silently: Check that the drive is connected before the backup window starts. Review your backup software's log files for error details.
- Drive does not eject: Close any open File Explorer or Finder windows showing the drive contents, then try ejecting manually.
- Scheduled task does not run: Open Task Scheduler, find your task, and check the History tab. Ensure the computer is awake at the scheduled time, or enable Wake the computer to run this task in the task's Conditions settings.
- macOS launchd job does not run: Verify the plist file is loaded with
launchctl list | grep eject-backup. Check Console.app for any error messages related to your script.
Still Having Issues?
💻 Open a Ticket