[PowerShell] A backup script

I once heard the saying that people are divided into two types: those who backup and those who will backup. Everyone who has lost their data certainly understands this saying.

To avoid this situation, I back up my folders from time to time. To automate it a bit I created a simple script in powershell.

The idea

The idea of the script is that I create a 7-zip archive of the most important folders for me. I create a separate archive for each folder. The archives are not password protected. When the script ends, all archives are uploaded to an external disk, which is connected to the computer only for the time of copying the archive.


To be able to create *.7z archive we need 7-zip program installed. You can download the program from here: https://www.7-zip.org/.


Script is very simple:

& "D:\Programy\7-Zip\7z.exe" -mx=9 a "D:\Pobrane\Oprogramowanie" "D:\Oprogramowanie"

At the beginning we provide the access path to the installed 7-zip program.


The next are the compression parameters for 7-zip. x = 9 for example means the highest level of compression.


The next item is the path where the archive will be placed on the disk.


Finally, enter the path to the folder you want to archive.


We create a separate script line for each folder that we want to archive.


The script is very simple. It is enough to run the script once in a while. Powershell will make backup copies for our important folders. After that it remains only to copy the .7z archives to an external disk.