Open main menu

CDOT Wiki β

Changes

OPS245 Lab 2

62 bytes removed, 13:30, 3 February 2021
m
Part 3: Using Shell Scripts for VM Backup & Management: - moving away from using root, to admin user with sudo
{{Admon/important|Virtual Machine Does not Shutdown from Command|If the Virtual machine fails to shutdown from the <code>virsh shutdown</code> command, then you can go to the '''Virtual Machine manager''' and '''halt''' or '''shutdown''' within the VM itself, then you can click the '''PowerOff''' button in the VM window. You'll want to avoid a forced shutdown since those are equivalent to yanking the power cord out of the wall on a physical machine!|}}
<ol><li value="8">Open a Bash shell terminal.</li>
<li>Use elevated privileges to create a directory called /root/bin.</li><li>Use a text editor (such as <b><code><span style="color:#3366CC;font-size:1.2em;">vi</span></code></b> or <b><code><span style="color:#3366CC;font-size:1.2em;">nano</span></code></b>) to create a Bash Shell script called: <b><code><span style="color:#3366CC;font-size:1.2em;">backupVM.bash</span></code></b> in your '''/root/bin''' directory.</li>
<li>Enter the following text content into your text-editing session:</li></ol>
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
<ol>
<li value="15">Save, set permissions, and then run that shell script to backup centos1. Since that script will only work if you are in have root's home directorypermissions, you will need to use the technique you learned earlier in this lab to temporarily become rootrun the command with elevated privileges. Confirm that this script did backup this image to root's your home directory</li><li>Use the <b><code>wget</code></b> command to download, study, and run the following shell scripts on-line:<blockquote><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">https://ict.senecacollege.ca/~ops235/labs/vm-start-text.bash<br>https://ict.senecacollege.ca/~ops235/labs/vm-stop-text.bash</span></code></b><br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">https://ict.senecacollege.ca/~ops235/labs/vm-start.bash<br>https://ict.senecacollege.ca/~ops235/labs/vm-stop.bash</span></code></b></blockquote></li><li>Try to understand what these Bash Shell scripts do.</li></ol>
932
edits