Schedule your task.
Just like the Linux daemon, you can do something similar on the WIndows system. Here’s how.
One of the most commonly used batch files at work is the task scheduler, which executes commands within the file at a scheduled time. Here’s an example.
This batch file sets up variables for the source folder to be backed up, the destination folder for the backup, and the filename of the resulting backup archive. It then uses PowerShell’s Compress-Archive
cmdlet to compress the contents of the source folder into a ZIP archive in the destination folder using the specified filename.
@echo off
set backup_source=C:\original\path
set backup_destination=D:\backup\backup_compress
set backup_filename=eclipse_%date:~-4,4%%date:~-7,2%%date:~-10,2%.zip
echo Starting backup of %backup_source% to %backup_destination%...
powershell Compress-Archive -Path "%backup_source%" -DestinationPath "%backup_destination%\%backup_filename%"
echo Backup completed at %time% on %date%.
How to schedule the task:
Once you finished creating the task, follow the instructions below to schedule the task.
- Open Task Scheduler from the Control Panel or Start menu. (To open the task scheduler in Win 10, press the Windows key on your keyboard or click/tap inside the Search box on the taskbar, and then type the words task scheduler)
- Click “Create Task” in the Actions pane on the right-hand side.
- In the General tab, give the task a name and select the appropriate operating system version under “Configure for.”
- In the Triggers tab, click “New” to create a new trigger for the task, and specify when you want the task to
- run (e.g., daily, weekly, at log on, etc.).
- In the Actions tab, click “New” to create a new action, and specify the path to the batch file you want to run (e.g., C:\backup.bat).
- In the Conditions and Settings tabs, configure any additional options or settings you want for the task.
Click “OK” to save the task.