932
edits
Changes
m
→UNDER CONSTRUCTION: - fixing a typo
for machine in {'centos1','centos2','centos3'}:<br />
print('Backing up' + machine)<br />
os.system('gzip < /var/lib/libvirt/images/' + machine + '.qcow2 > ~/backups/' + machine + '.qcow2.gz')<br />
</code>
<li>Now that the script recognizes you as being root (or at least running the script with root permissions), it should work. Notice how we've used the + to combine several strings together to pass to the os.system command. We did this because this script needs the python variable to be evaluated before the whole line gets handed over to os.system. If you left the variable names inside the quotes, python will ignore them as just being part of a string. By putting them outside of a string, and concatenating their value to that string, we can evaluate them and feed them into that command.</li>
</ol>
= LAB 2 SIGN-OFF (SHOW INSTRUCTOR) =