using backups in power shell

urp2054
timer Asked: Oct 16th, 2017

Question Description

  • In the Windows server environment, you will create two separate scripts within PowerShell that will perform two types of backups of a given source directory and store the backed up files in a given target directory (preferably on a separate drive). The first script will perform a full backup and the second script will perform an incremental backup on the remaining days of the week. Lastly, using the Microsoft Management Console Task Scheduler, you will set up a schedule for the first script (the full backup script) to run on Sundays and Wednesdays and a schedule for the second script (the incremental backup script) to run on the remaining days of the week.

Unformatted Attachment Preview

Final Backup Research CSIS 352 July, 3 2017 IN ADDITION TO THIS EXAMPLE, PLEASE ENSURE YOU ARE ADAPTING APA FORMATTING FOR THE COMPLETE PAPER. COVER PAGE CONTENT HEADING SUB HEADING- if any In-Text Citations REFERENCES Setting up a Windows (Powershell) Backup First we needed to build the full backup script. This powershell script will grab all the files in the source directory and copy to the backup directly. We also use a staging directory just for purposes of a failed backup it will allow for a successful data retrieval of the good files without overwriting them. Full Backup Script $ErrorActionPreference = "Stop" $sourcefolder = "C:\files" $staging = "C:\staging" $destfolder = "C:\backup" Remove-Item $destfolder\* -Recurse -Force Copy-Item -Path $sourcefolder\* -Destination $staging -Recurse -Force Copy-Item -path $staging\* -Destination $destfolder -Recurse -Force Remove-Item $staging -Recurse -Force The next powershell script will take only files that have been modified in the last day therefore making this an incremental backup. This allows so that only new/modified files are backed up on a regular day and will ultimately save space. Incremental Backup Script $ErrorActionPreference = "Stop" $sourcefolder = "C:\files" $staging = "C:\staging" $destfolder = "C:\backup" $days = 1 Remove-Item $destfolder\* -Recurse -Force $FilesToCopy = Get-ChildItem $sourcefolder -force -recurse| where-object {($_.LastWriteTime -gt (Get-Date).AddDays(-1)) -and ($_.PSIsContainer -ne $True)} $count = 0 Foreach($File in $FilesToCopy) { $src_file = $File.Fullname.tolower() $dst_file = $File.Fullname.tolower().replace($sourcefolder, $staging) $dst_dir = Split-path -path $dst_file if (!(Test-Path -path $dst_dir) ) { Write-Host "`t Create directory " $dst_dir New-Item -path $dst_dir -type Directory | out-null } Copy-Item $src_file -Destination $staging $count++ } Copy-Item -path $staging\* -Destination $destfolder -Recurse -Force Remove-Item $staging\* -Recurse -Force Setting Up Task Scheduler We will store these scripts in the C:\ directory and build the task scheduler jobs in Windows via MMC. After building the jobs we will test each script so that it properly copies the files via the incremental and full backup methods. We will configure the triggers for the full backup as shown in Figure 1. Figure 1 Edit Task Schedule Under actions we will point to the full backup script powershell location as shown in Figure 2. Figure 2 Setup Task Scheduler Trigger Once we are done setting up the full backup we will also need to configure the daily incremental backup for the rest of the days of the week. We will point the action to the incremental/daily backup script that we created earlier as shown in Figure 3 and Figure 4. Figure 3 Setup Trigger Figure 4 Setup Actions Testing the Backup Scripts After doing the script configurations and scheduling the backup jobs, although we can be confident that the scheduled jobs will run as intended, we can go ahead and run them on demand since we obviously don’t want to wait all week to make sure the backups are working correctly. First we will test the full backup job, see the folder contents of what we will be backing up below. Empty backup folder We will go to task scheduler and run the full backup job on demand as shown in the figure above. After running the scheduled job on-demand we can see the files populate in the backup folder. Next we will test the incremental job, we will create a new job in the files directory and also add an older file that we would expect not to get copied during incremental. We will monitor the output backup directory and see if the file that we created shows up, and hope that the older file that we added into the directory does not get copied over to the backup directory. Source files directory Backup output directory We will run this incremental job the same way that we did with the full backup, but obviously we will choose incremental backup in MMC The backup output directory is just as we anticipated and the new file copied over but the old exe that we copied in didn’t get copied over during the incremental update. Setting up a Linux Backup First we will create two bash jobs and set the appropriate permissions to allow it to be executed. The bash jobs are below as follows. Full Backup Script #!/bin/bash rsync -ravzXI --inplace --delete /home/alex/files/ /home/alex/backup/ Incremental Backup Script #!/bin/bash rsync -ravzX --inplace --delete /home/alex/files/ /home/alex/backup/ We will then setup our crontab so that it includes the two scripts and configure the full backup to run on Sundays and Wednesday and the incremental backup to run the rest of the days. Contents of the files directory Empty backup directory Since we don’t want to wait for so long for the crontab to execute we will go ahead and execute the batch scripts manually. As you can see in the screenshot from the verbose output, we are running the full backup. We then ran the incremental backup and you can tell that no files were copied from the output. Next we added a file into the source files folder and ran the incremental backup once more to see if it will get picked up, and in fact it did. Contents of the backup directory after backup We were able to verify that our backup is working successfully on the Ubuntu system and can have peace of mind that our data will not be lost, that’s if we configure the backups properly and to multiple external devices. CSIS 352 FINAL PROJECT INSTRUCTIONS Earlier in the course, you learned about Services. An often neglected but critical service is running backups. This project serves as a first step towards creating and then automating the backup process in both the Windows and Linux environments. This project requires that you use an existing install of Windows Server from Project 1 and Ubuntu Server from Project 2. You will include a reflective paper of at least 2 pages in current APA format that details the installations, configurations, challenges, and solutions to complete the following systems administration project: 1) In the Windows server environment, you will create two separate scripts within PowerShell that will perform two types of backups of a given source directory and store the backed up files in a given target directory (preferably on a separate drive). The first script will perform a full backup and the second script will perform an incremental backup on the remaining days of the week. Lastly, using the Microsoft Management Console Task Scheduler, you will set up a schedule for the first script (the full backup script) to run on Sundays and Wednesdays and a schedule for the second script (the incremental backup script) to run on the remaining days of the week. 2) Provide three pieces of evidence showing that your scripts were successful: 1) a copy of your scripts; 2) clear screenshots of the Task Scheduler interface showing the correctly scheduled tasks; and 3) results of the backup processes (specifically the files in both the source and target directories). 3) In the Ubuntu environment, you will perform the same tasks as the last two steps. You will create two separate BASH scripts that will perform two types of backups of a given source directory and store the backed up files in a given target directory (preferably on a separate drive). The first script will perform a full backup and the second script will perform an incremental backup on the remaining days of the week. For assistance with this, Google “incremental backup script in bash” for starters. Once you have these scripts working, use the cron command to schedule the scripts. As the previous steps dictate, you will set up a schedule for the first script (the full backup script) to run on Sundays and Wednesdays and a schedule for the second script (the incremental backup script) to run on the remaining days of the week. 4) Provide three pieces of evidence showing that your scripts were successful: 1) a copy of your scripts; 2) clear screenshots of the scheduled scripts using crontab or the contents of the /etc/cron.* directories showing the correctly scheduled tasks; and 3) results of the backup processes (specifically the files in both the source and target directories). Page 1 of 2 CSIS 352 The paper must use appendixes to reference screenshots along the way. Screenshots must identify a unique piece of information on the user’s computer such as a picture and include the system date and time in each screen capture. At the minimum, screenshots must exist during the initial setup of VirtualBox, installation of the operating system, configuration of the user accounts, security updates, and firewall configuration of the new operating systems. Subsequent screenshots must exist that detail the other deliverables in each phase (e.g., such as DNS). This assignment must be submitted to SafeAssign by 11:59 p.m. (ET) on Friday of Module/Week 8. Page 2 of 2
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors