Sunday October 26 2025

How to create a simple script to backup in Windows

Create a script to automatically backup files in Windows with PowerShell
 script that automatically creates backups in Windows.

Step-by-step guide to creating a simple backup script in Windows »

Protect your data every day in a simple way

 You're working for hours on an important document, taking a photo, or creating something that took you days. And suddenly... your computer freezes or the file gets lost. It's not a nightmare – it happens!

The good news? You can create your own backup system that runs automatically every day, without having to be a computer expert or write commands. All you need is a simple file that runs with a double-click!

What you will need to get started

Before we start, let's see what you need:

  • A Windows computer
  • The folder you want to protect (e.g. "My Documents", "Photos", etc.)
  • Place where the copies will be stored (e.g. external drive or another folder on your computer)
  • 5-10 minutes of your time

Step 1: Create the backup file

1. Open Notepad.
2. Paste the code you will find below
3. Click "File" → "Save As"
4. Give a name like BackupScript.bat and select "All files"
5. Click "Save" and you're done!
💡 Tip: The file .bat your assistant that will do all the work for you. With a double click, it creates a new folder with a date and copies your files automatically!

Step 2: Write the Backup Script

Now we will create the commands that will perform the backup. Copy the following code:

@echo off setlocal :: Define source and destination folders set "source=C:\Users\Admin\Downloads" set "destination=I:\Backup" :: Create timestamp for /f %%i in ('powershell -Command "Get-Date -Format 'yyyy-MM-dd_HH-mm'"') do set "timestamp=%%i" set "backupFolder=%destination%\Backup_%timestamp%" :: Create backup folder powershell -Command "New-Item -ItemType Directory -Path '%backupFolder%' -Force |. Out-Null" :: Copy files powershell -Command "Copy-Item -Path '%source%\*' -Destination '%backupFolder%' -Recurse -Force" :: Show success message echo. echo ✅ Backup completed successfully! echo 📁 Saved to: %backupFolder% echo. pause
⚠️ Attention: Before running the script, you need to change two things:
  • source: Enter the path of the folder you want to backup here.
  • destination: Enter the folder where you want the copies to be saved here.

How to find the path of a folder?

Easy! Open the folder you want, click on the address bar (top right) and the full path will appear. Copy it and paste it into the script.

Example: If your documents are located in "C:\Users\Admin\Downloads", then source=C:\Users\Admin\Downloads

Example for destination: If you want the copies to be saved on an external drive in the Backup folder, then destination=I:\Backup

Step 3: Save the Script

1. Open Notepad.
2. Paste the script code
3. Click "File" → "Save As"
4. Choose a folder (e.g. C:\Scripts)
5. Give a name like BackupScript.bat
6. In the "Save as type" field, select All files
7. Codification: UTF-8
8. Click "Save"
💡 Important: The file must end in .bat — so you can run it with a double click!

Step 4: Running the Script

Now you're ready to try it:

1. Double-click the file. BackupScript.bat
2. A black window with information will appear.
3. If everything went well, you will see the message "Backup completed successfully!"
4. Open the destination folder and you will see a new folder with a date, e.g. Backup_2025-10-08_10-09
The script is running.

Step 5: Set Execution Time (Task Scheduler)

If you want the backup to be done automatically every day, every week, etc., you can schedule it with Task Scheduler (Task Scheduling).

How to open Task Scheduler in Windows 11

1. Press the button. Windows and write taskschd.msc
2. Press Enter to open the tool.

Creating a daily task

3. In Task Scheduler, go right and click Create Basic Task (Creating a Basic Task)
4. Give it a name like Καθημερινό Backup and foot Next (Next)
5. Choose Daily (Daily) and press Next (Next)
6. Set the time you want it to run (e.g. 23:00 every night) and press Next
7. Choose Start of the program (Start program) and press Next
8. In the Program / script (Program/script), write the full path of the file BackupScript.bat
9. Example: C:\Scripts\BackupScript.bat
10. Pat Next (Next) and after Finish (End)

WATCH THIS

backup-step1 backup-step2 backup-step3 backup-step4 backup-step5 backup-step6
💡 Tip: Choose a time when your computer is usually on but you're not actively using it — like at night before bed or at noon.

FAQ

What happens if my computer is turned off during the backup?

You can set it. Task Scheduler (Task Scheduler) to run the backup the next time you turn on the computer. Just right-click on the task, go to settings and check "Run task as soon as possible after a scheduled start is missed" (Perform the task as soon as possible if the scheduled time was missed).

How much space do I need?

It depends on your files and how many backups (copies) you want to keep. If you keep 7 backups and your files are 10GB, you need about 70GB. That's why we recommend an external drive!

It is safe;

Yes! The script simply copies files – it does not delete or modify the originals. Your original files remain intact.

Can I backup multiple folders?

Of course! Just repeat the commands. Copy-Item (Copy item) for each folder you want to protect or create separate scripts (command files).

Why It's Worth Doing

  • Calm: You know your files are safe
  • Automation: You don't have to remember to do it manually.
  • Free: No service subscriptions cloud (cloud computing)
  • Control: Your data remains in your hands.
  • Flexibility: You can customize it as you wish.
  • Learning: You better understand how your computer works

Conclusion

Creating a system backup (backup) isn't as hard as it seems! With a few simple steps, you can protect your valuable data and sleep soundly every night. Most importantly? When something goes wrong (and it will), you'll be ready. Instead of losing years of memories or hours of work, it only takes a few clicks to recover them.


Evangelos
✍️ Evangelos
Its creator LoveForTechnology.net — an independent and trusted source for tech guides, tools, software, and practical solutions. Each article is based on personal testing, evidence-based research, and care for the average user. Here, technology is presented simply and clearly.



RELATED TOPICS


💬 Comments

Share your thoughts

Loading comments...