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

System Administration Scripting Part A. In the Windows server environment, you w

ID: 3581936 • Letter: S

Question

System Administration Scripting

Part A. 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.The first script will perform a full backup and the second script will perform an incremental backup on the remaining days of the week.

Part B. 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. The first script will perform a full backup and the second script will perform an incremental backup on the remaining days of the week.

Explanation / Answer

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