1 / 4100%
Performing Backups with Windows Assignment
This project was overly complicated for me with the incremental backup part. I had a lot
of trouble with the script which led me to research and get help getting the right commands to
finally run the incremental backup. During this project, the requirements were to work on a pre-
installed Windows virtual server, create two different scripts that would be ran by PowerShell
and then perform two different backups with those scripts we created. Microsoft PowerShell is a
command-line shell and scripting language that comes standard with Windows. It contains an
interface that allows programmers to access operating system services and is based on
Microsoft's.NET framework.
The files were stored in a target directory and put into a separate folder. The first script
was used to perform a full backup and the second script was used to perform an incremental
backup. After completing the scripts and running them successfully, Microsoft Management
Console Task Scheduler was used to set up the full backup script to run two days of the weeks
and the incremental backup to run on the remaining days. This reflection will go over how to
write the scripts for the full-backup, incremental backup, and using Task Scheduler to create
scheduled backups for the two scripts.
Writing Backup Script
I started researching how to perform a full back up using PowerShell on Windows.
Vignesh (2016) provided a helpful video on YouTube that I followed along with. First, you create
or find a folder called BackupsTest that will go into another folder called Staging” which will
copy the data and then move it into the backup destination BackupLog.” After creating these
folders, I started writing the script. I first specified the action preference to halt to ensure that the
data was not deleted, and then I specified the folder BackupsTest for the source. I then used the
command Remove-Item to delete all files currently stored on the backup location. I also used
Force and Recurse to get around any access problems or prompts. I then entered the path
where I wanted all files duplicated, which was the Staging” folder, as well as the recurse and
force options. I also used the wildcard character \* to ensure that it did not simply replicate an
empty folder. And then everything was backed up to the backup location BackupLog” and I
deleted all the files from there. You can see that the files were deleted and saved to the backup
location after running my code.
Writing Incremental Backup Script
To write this script, I found a very helpful website, which contained a how-to guide.
This script takes it a step further and prompts the user to input what files to backup, as well as
specify a timeframe to only backup files that have been recently changed. The script recursively
analyzes the files in the source location and sub-folders, obtaining a list of files that have been
modified in the last (user prompted) days and copying them to the destination folder. All three
parameters are required. The Get-ChildItem and where-object cmdlets are piped together to
find files in the source location that have a LastWriteTime property that is within the last (user
prompted) days. The value of Int is supplied as a parameter to the script. Then I used a
Foreach” loop to iterate over the list of files to be transferred and to check if the directory
structure exists in the destination. If the directory does not exist, we create it with the New-
Item cmdlet.
Using Task Schedular
My next step was to use Microsoft's task scheduler to establish scheduled backups. The
Task Scheduler is a Windows tool that allows specified operations to be executed automatically
when a specific set of conditions is met. From there, I chose create simple task” option and
titled my first task as backup. I then went into the triggers menu and chose weekly and set it to
run every Sunday and Wednesday. After that, I went into the action menu and chose run a
program option, specified the path for the script I wanted to use to perform my full backup. I
then repeated the process for my incremental backup, but this time I chose the remaining days of
the week rather than Sunday and Wednesday. After that, I was able to see both the entire backup
and the incremental backup that I had produced and confirm that the dates were correct.
Conclusion
In conclusion, I learned a lot from this assignment. I had to research things that I didn’t
understand fully, and now I have a more confident understanding. Scheduling the tasks to run
was the easiest part of the assignment for me as I was already knowledgeable in this area.
However, I had to research how to specify my path for where my script was located. I wanted to
take this assignment a step further and create a new drive for the backup folder, but the
cyberscore work environment didn’t allow me to do so. A separate document will contain all of
my screenshots and my scripts.
References
PowerShell script for incremental backup using modified time. (n.d.). PowerShell Script for
Incremental Backup Using Modified Time. https://www.opentechguides.com/how-
to/article/powershell/130/incremental-backup-script.html
Backup files Using Powershell. (2016, January 31). YouTube. https://www.youtube.com/watch?
v=M2niZySRS-8
Inc., S. (n.d.). Run PowerShell Scripts from Task Scheduler. How to Run PowerShell Scripts
From Task Scheduler. https://community.spiceworks.com/how_to/17736-run-powershell-scripts-
from-task-scheduler
Powered by TCPDF (www.tcpdf.org)
Students also viewed