I started looking at this - and immediately wandered into the TrueNAS CLI
"service vm query" will list, in way too much detail the VM's running
"service vm stop 'n'" will stop a VM
"service clone 'n'" will clone a VM
"service vm start 'n'" will start a VM
[N.B. These command are not shell, but CLI]
Testing of stop indicates a clean shutdown in progress - I just have a stupid app in the VM that requires a long time to shutdown. However the stop command does return a 100% well before the VM is actually shutdown. This I would describe as a bug allbeit not a major one.
Testing of clone creates a clone of the zvol in the same dataset
Testing of start does do a start - works just fine
On the subject of the clone:
- Note the size of the clone in comparison to the original. This would imply to me that its a snapshot clone (is that the right phrase) rather than a full clone
- Its a very quick operation - a few seconds
- Under virtualisation (GUI) I get
So what I thought was how about writing a script to do the following:
- Stop a VM
- Clone a VM
- Start a VM
- Replicate the cloned zvol as a backup - that way I should get an application-consistent backup as opposed to a crash-consistent backup
- Delete the clone
Note that every time you clone a VM it clones to a new VM BUT the ID is incremented by one (this will probably reset on a reboot), even if you delete a previous clone. I can forsee the need to search the service vm query output to find the source VM and then search it again for the clone name so the zvol can be replicated.
The CLI commands can be run from the bash prompt as
Code:
cli -c "service vm query"
which will produce the output
Code:
+----+---------------------+---------------------+-------+--------+------------+-----------+-------+------------+-------+---------+-----------------------+------------------+------------+-----------+--------+---------+-----------+---------------+---------------------+-----------------------+-----------+--------------+--------------------------------------+-------------------+-----------------+-------------------------+---------+--------+
| id | name | description | vcpus | memory | min_memory | autostart | time | bootloader | cores | threads | hyperv_enlightenments | shutdown_timeout | cpu_mode | cpu_model | cpuset | nodeset | pin_vcpus | hide_from_msr | suspend_on_snapshot | ensure_display_device | arch_type | machine_type | uuid | command_line_args | bootloader_ovmf | trusted_platform_module | devices | status |
+----+---------------------+---------------------+-------+--------+------------+-----------+-------+------------+-------+---------+-----------------------+------------------+------------+-----------+--------+---------+-----------+---------------+---------------------+-----------------------+-----------+--------------+--------------------------------------+-------------------+-----------------+-------------------------+---------+--------+
| 2 | Ubuntu_Docker_20_04 | Ubuntu_Docker_20_04 | 4 | 16384 | <null> | true | LOCAL | UEFI | 2 | 1 | false | 90 | HOST-MODEL | <null> | <null> | <null> | false | false | false | true | <null> | <null> | b4f582a7-bcba-4e84-ba42-a8d8738b019b | | OVMF_CODE.fd | false | <list> | <dict> |
+----+---------------------+---------------------+-------+--------+------------+-----------+-------+------------+-------+---------+-----------------------+------------------+------------+-----------+--------+---------+-----------+---------------+---------------------+-----------------------+-----------+--------------+--------------------------------------+-------------------+-----------------+-------------------------+---------+--------+
Which if it didn't wrap around on the screen would be great - as it is its less than 100% human readable, not that it really needs to be