Changes

Jump to: navigation, search

OPS245 Lab 2

34 bytes removed, 01:36, 25 January 2021
m
Part 3: Using Shell Scripts for VM Backup & Management
# Switch to the '''c7host''' machine, and open a shell terminal.
# Enter these admin commands into your '''c7host''' machine and note the result:
:: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo virsh list</span></code></b>:: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo virsh list --all</span></code></b>:: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo virsh list --inactive</span></code></b><ol><li value="4">Now, shut-down your centos1 VM normally, and close the centos1 VM window.</li><li>Switch to your terminal and issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">sudi virsh start centos1</span></code></b></li><li>Using the appropriate command check to see if your centos1 VM is now running.</li><li>There are other commands that can be used (such as '''suspend''', or '''shutdown'''). The "shutdown" command may not always work since it relies on the guest handling a particular ACPI event. Why do you think it is useful to have commands to manipulate VMs?</li></ol>
{{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="9">Open a Bash shell terminal.</li>
&nbsp;do<br>
&nbsp;&nbsp;echo "Backing up VM #$num"<br>
&nbsp;&nbsp;gzip < /var/lib/libvirt/images/centos$num.qcow2 > ~YourRegularUsername/backups/centos$num.qcow2.gz<br>
<br>&nbsp;&nbsp;echo "VM #$num BACKUP DONE"<br>
&nbsp;done<br><br>
&nbsp;done<br>
&nbsp;echo "Backing up VM #$numanswer"<br>
&nbsp;gzip < /var/lib/libvirt/images/centos$numanswer.qcow2 > ~YourRegularUsername/backups/centos$numanswer.qcow2.gz<br><br>
&nbsp;echo "VM #$numanswer BACKUP DONE"<br>
else<br>
572
edits

Navigation menu