onedb
- OpenNebula database migration tool
This command enables the user to manage the OpenNebula database. It provides information about the DB version, means to upgrade it to the latest version, and backup tools.
-a, --append Append new attributes to the current template
-b, --backup file Use this file to store SQL dump
-d, --dbname dbname MySQL or PostgreSQL DB name for OpenNebula
-d, --delete Delete all matched xpaths
--dry Do not write in the database, output xml
--encoding charset MySQL or PostgreSQL encoding to use for the
connection
-e, --end TIME Last time to process
-e, --expr ID Filter by expression (UNAME=oneadmin)
--extra arg Extra args
--federated Limit backup/restore to federated tables
-f, --force Forces the backup even if the DB exists
-h, --help Show this message
-i, --id ID Filter by ID
--no-backup If used the backup file won't be automatically
generated. Not recomended for production
environments
--pages pages Nummber of pages to purge VMs
-p, --password pass MySQL or PostgreSQL password. Leave unset to be
prompted for it
-P, --port port MySQL or PostgreSQL server port. Defaults to 3306
for MySQL and 5432 for PostgreSQL
--recreate Delete FTS index and create a new one
--seq SEQ Sequence number of a hitory record
-S, --server host MySQL or PostgreSQL server hostname or IP.
Defaults to localhost
-s, --sqlite file SQLite DB file
-s, --start TIME First time to process
-t, --type type Backend type.
-u, --username user MySQL or PostgreSQL username
-v, --verbose Verbose mode
-V, --version Show version and copyright information
-x, --xpath ID Filter by xpath
backup [output_file] Dumps the DB to a file specified in the argument valid options: federated, force
change-body
You can filter the objects to modify using one of these options:
* --id: object id, example: 156
* --xpath: xpath expression, example: TEMPLATE[count(NIC)>1]
* --expr: xpath expression, can use operators =, !=, <, >, <= or >=
examples: UNAME=oneadmin, TEMPLATE/NIC/NIC_ID>0
If you want to change a value use a third parameter. In case you want
to delete it use --delete option. In canse you want to append a new
attribute use --append option.
Change the second network of VMs that belong to "user":
onedb change-body vm --expr UNAME=user \
'/VM/TEMPLATE/NIC[NETWORK="service"]/NETWORK' new_network
Delete cache attribute in all disks, write xml, do not modify DB:
onedb change-body vm '/VM/TEMPLATE/DISK/CACHE' --delete --dry
Delete cache attribute in all disks in poweroff:
onedb change-body vm --expr LCM_STATE=8 \
'/VM/TEMPLATE/DISK/CACHE' --delete
Append cache attribute in all disks in poweroff:
onedb change-body vm --expr LCM_STATE=8 \
'/VM/TEMPLATE/DISK/CACHE' default --append
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: append, delete, dry, expr, id, xpath
change-history xpath value Changes a value from a history record of a VM. History records are defined by its sequence number (SEQ) and VM ID.
* --id: vm id, example: 156
* --seq: sequence number of the record, example: 0
The new value for this elemente is set in the third parameter.
Change the the hostname of first record:
onedb change-history --id 3 --seq 0 '/HISTORY/HOSTNAME' new_host
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: dry, id, seq
create-index Create or recreate FTS index in vm pool to be able to search VMs valid options: recreate
fsck Checks the consistency of the DB, and fixes the problems found valid options: backup, force
history Prints the upgrades history
patch file Applies a database patch file valid options: backup, extra
purge-done Deletes all VMs in DONE state
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: end_time, pages, start_time
purge-history Deletes all but the last history records from non DONE VMs
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: end_time, start_time
restore backup_file Restores the DB from a backup file. Only restores backups generated from the same backend (SQLite or MySQL) valid options: federated, force
show-body
* --id: object id, example: 156
For example to show the XML document of VM 23:
onedb show-body vm --id 23
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: id
show-history Show body of a history record. History records are defined by its sequence number (SEQ) and VM ID:
* --id: vm id, example: 156
* --seq: sequence number of the record, example: 0
For example to show the 3rd record of VM 0
onedb update-history --id 0 --seq 3
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: id, seq
sqlite2mysql Migrates a SQLite OpenNebula Database to MySQL valid options: backup
update-body
* --id: object id, example: 156
For example to update the XML document of VM 23:
onedb update-body vm --id 23
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: id
update-history Update history record of a VM. History records are defined by its sequence number (SEQ) and VM ID:
* --id: vm id, example: 156
* --seq: sequence number of the record, example: 0
For example to update the 3rd record of VM 0
onedb update-history --id 0 --seq 3
**WARNING**: This action is done while OpenNebula is running. Make
a backup of the datasbase before executing.
valid options: id, seq
upgrade [version] Upgrades the DB to the latest version where version : DB version (e.g. 1, 3) to upgrade. By default the DB is upgraded to the latest version valid options: backup, force, no_backup
vcenter-one54 Migrate VM and templates so they can be used by OpenNebula 5.4 valid options: backup, force
version Prints the current DB version. Use -v flag to see also OpenNebula version
The version command will return different RC depending on the current
state of the installation:
- 0: The current version of the DB match with the source version.
- 1: The database has not been bootstraped yet.
- 2: The DB version is older than required (upgrade needed).
- 3: The DB version is newer and not supported by this release.
- -1: Any other problem (e.g connection issues)
file Path to a file
range List of id's in the form 1,8..15
text String