Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the Windows server environment, you will create two separate scripts within P

ID: 3596598 • Letter: I

Question

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. Does anyone know how to do this?

Explanation / Answer

Solution:

PowerShell script:

#System Variable for backup Procedure

#Get date in the current format.
$date = Get-Date -Format d.MMMM.yyyy

# Filesystem path
New-PSDrive -Name "Backup" -PSProvider Filesystem -Root "\T_ServerTally"

# From where to backup.
$source = "D:TallyData"

# Where to backup.
$destination = "backup:$date"

# Check if the path is correct.
$path = test-Path $destination


# Backup Process started
if ($path -eq $true) {
   write-Host "Directory Already exists"
Remove-PSDrive "Backup"
}
elseif ($path -eq $false) {
   cd backup:
mkdir $date
copy-Item -Recurse $source -Destination $destination
$backup_log = Dir -Recurse $destination | out-File "$destinationackup_log.txt"
$attachment = "$destinationackup_log.txt"

cd c:
Remove-PSDrive "Backup"
}

BASH script:

#!/bin/bash
# Print Pre-text Containing Script Version Info & Creator Info (please leave current credits intact and add a separate line if you modify the script & pass it on)
clear
echo "Backup Script"
echo ""
echo "V.1.3"
echo ""

read -p "Please Press ENTER To Continue..." waitForEnter

# Alert The User & Wait 3 Clicks
echo "BACKUP Initiating..."
echo ""

sleep 3

# Ask The User For Their Current Username (For Backup File Placement & Permissions)
read -p "What username are you currently logged into? (must be IDENTICAL to username you are currently using!!): " backupUser

# Backup Entire System To the Specified User's homedir/backup.tgz (../../ included so script can be put in subdirectory)
sudo tar cvpzf ../../home/$backupUser/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/media /

# Upon Completion Of Backup, Alert The User
echo ""
echo "BACKUP Complete!"
echo ""

# Then Set backup.tgz File Privilidges So That The Specified USER Can Read, Write & Execute
echo "Setting Backup File Privilidges..."
echo ""

# Set The File's Group As the Specified $backupUser
chgrp $backupUser ../../backup.tgz
  
# Set Read, Write & Execute Privilidges For The Owner (root)
chmod u+rwx ../../backup.tgz
  
# Set Read, Write & Execute Privilidges For The Specified Group ($backupUser)
chmod g+rwx ../../backup.tgz
  
# Alert The User, Wait 3 Clicks & Terminate The Script
echo "TERMINATING..."
echo ""
sleep 3
# End Of Backup.sh Script

Please, please upvote and ask your doubts in the comments.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote