Skip to main content

ManageIQ Database Backup and Restore

Hybrid-Cloud-Automation-Using-Ansible-ManageIQ

Nowadays, Automation is the mother of all the inventions, that give rise to all the new technologies. Most of the latest technologies are the reason for automation. This project is one of our tries to automate hybrid cloud using ManageIQ and Ansible.

A hybrid cloud is the one with the combination of both i.e. private as well as public cloud with the specified specifications.

ManageIQ is an open-source cloud management platform by Red Hat. It is written in Ruby with RoR (Ruby on Rails) as the platform.

Ansible is software that automates software provisioning, configuration management, and application deployment. Playbooks are Ansible’s configuration, deployment, and orchestration language.

Introduction to ManageIQ

  • ManageIQ is an Open Source Cloud management platform. The ManageIQ project founded by Red Hat In 2014 as a community project. It is written in Ruby with RoR (Ruby on Rails) as the platform.
  • For getting started get a ManageIQ instances from here

Installation

  • Using KVM/Qemu image

    • Download ManageIQ Image from manageiq/downloads choose QEmu/KVM

    • Install KVM and necessary packages

yum install qemu-kvm libvirt libvirt-python virt-install

  • Create ManageIQ VM using an existing image

    • Create VM using virt-install command

sudo virt-install --virt-type kvm  --import --name ManageIQ  --memory 12288 --vcpus 4 --cpu host  --disk manageiq-openstack-gaprindashvili-5.qc2,format=qcow2,bus=virtio  --network default,model=virtio   --os-type=linux --os-variant=centos7.0   --graphics spice

  • Launch VM using virsh
  • Login using ssh

ssh root@<ip_of_server>
    - user: _root_
    - password: _smartvm_

Appliance console and basic configuration

Running a command appliance_console ot ap to get into ManageIQ Virtual Appliance. It gives datails regarding ManageIQ Machine such as,

  • hostname
  • IPv4 Address
  • IPv4 Gateway
  • IPv6 Address
  • IPv6 Gateway
  • Primary DNS
  • Secondary DNS
  • Search Order
  • Mac Address
  • TimeZone
  • Local Database Server
  • ManageIQ Server
  • ManageIQ Database
  • Database/Region
  • External Auth
  • ManageIQ Version

Pressing Enter will lead to the Advanced Settings

  • Configure Network
  • Set Timezone
  • Set Date and Time
  • Restore Database From Backup
  • Configure Database
  • Configure Database Replication
  • Logfile Configuration
  • Configure Application Database Failover Minitor
  • Configure External Authentication (httpd)
  • Update External Authentication Options
  • Generate Custom Encryption Key
  • Stop EVM server Processes
  • Start EVM server Processes
  • Restart Appliance
  • Shut Down Appliance
  • Summary Information
  • Quit

ManageIQ database configuration

ManageIQ uses PostgreSQL Database. So while dealing with ManageIQ database we’ll need to follow PostgreSQL commands and procedure to take a database dump as a backup and to restore it in another instance.

Note: ManageIQ uses "vmdb_production" database

This is list of steps followed to obtain a dump from a db then retsore it

Dump the Postgres DB:

  • stop the appliance(s):

systemctl stop evmserverd

This will stop the evmserverd.service from using database in background but no need to stop them, for creating backup the doesn’t affects anywhere.

  • dump the database into file:

pg_dump -Fc vmdb_production > production.dump

  • Copy the dump file to the other ManageIQ instance where the database have to restore.

    We can use scp for that as follows:

scp production.dump root@ip_of_other_instance:/root/

Import the Postgres dump

  • Take production.dump to the local machine.

  • Stop the backend processes

systemctl stop evmserverd

  • Drop existing database vmdb_production

dropdb vmdb_production

  • create new database named vmdb_production

createdb vmdb_production

  • restore the database from dump file

pg_restore -d vmdb_production "/path/to/production.dump

  • change directory to /var/www/miq/vmdb/tools

vmdb  #executing "vmdb" will take you to "/var/www/miq/vmdb/"

cd tools

bundle exec fix_auth.rb --v2 --invalid bogus

  • Start evm service

systemctl start evmserverd

This will do the task of restoring database manually.