1) In the Windows server environment, you will create two separate scripts withi
ID: 3596629 • Letter: 1
Question
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).
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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.