Automate Daily Backups with 7-Zip and Task Scheduler
This article provides a step-by-step guide on how to automatically create daily, timestamped ZIP archives of your important files using the free 7-Zip utility and the built-in Windows Task Scheduler. By combining a lightweight batch script with scheduled automation, you can establish a reliable, zero-cost backup system that runs seamlessly in the background without requiring manual intervention.
Step 1: Verify the 7-Zip Installation Path
7-Zip includes a command-line executable named 7z.exe.
By default, it is installed in:
C:\Program Files\7-Zip\7z.exe
Ensure 7-Zip is installed and verify that this path exists on your system.
Step 2: Create the Backup Batch Script
A Windows batch file will define what files to back up, create a unique filename based on the current date, and instruct 7-Zip to generate the archive.
- Open Notepad.
- Paste the following script:
@echo off
:: Define source directory and backup destination
set "SOURCE=C:\Users\YourUsername\Documents\MyData"
set "DEST=D:\Backups"
:: Generate a reliable YYYY-MM-DD timestamp
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /value') do set "DT=%%I"
set "DATESTAMP=%DT:~0,4%-%DT:~4,2%-%DT:~6,2%"
:: Create the archive name
set "ZIPNAME=Backup_%DATESTAMP%.zip"
:: Run 7-Zip command to compress files
"C:\Program Files\7-Zip\7z.exe" a -tzip "%DEST%\%ZIPNAME%" "%SOURCE%\*" -r -mx=5
exit /bScript Breakdown:
SOURCE: The folder you want to back up. Update this path to match your target folder.DEST: The folder where the backup file should be saved.a: Tells 7-Zip to add files to an archive.-tzip: Specifies the ZIP format (change to-t7zif 7z format is preferred).-r: Recurses subdirectories.-mx=5: Sets standard compression level (ranges from 0 for none to 9 for ultra).
- Save the file with the
.batextension, for example:C:\Scripts\daily_backup.bat.
Step 3: Test the Script
Before scheduling, verify the script functions properly:
- Double-click
daily_backup.bat. - Check your destination folder to ensure the new
.zipfile is created with today's date in the title and contains your files.
Step 4: Schedule the Script in Windows Task Scheduler
- Press
Windows Key + R, typetaskschd.msc, and press Enter. - In the right-hand Actions panel, click Create Basic Task.
- Name: Enter
Daily 7-Zip Backupand click Next. - Trigger: Select Daily and click Next.
- Time: Choose your desired daily execution time
(e.g.,
11:00:00 PM) and click Next. - Action: Select Start a program and click Next.
- Program/script: Click Browse and
select your
C:\Scripts\daily_backup.batfile. - Start in (optional): Enter the folder path where
the script is located (e.g.,
C:\Scripts\). - Click Next, review the summary, and click Finish.
Step 5: Configure Permissions (Optional but Recommended)
To ensure the backup runs even if you are not actively logged into the computer:
- Locate Daily 7-Zip Backup in the Task Scheduler Library.
- Right-click the task and select Properties.
- Under the General tab, select Run whether user is logged on or not.
- Check the box labeled Run with highest privileges.
- Click OK and enter your Windows account password when prompted.