How can I check for existence of a vdb

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Hi - I am trying to automate provisioning of VDBs, while doing it I also want to check for existence of a VDB and if it exists I want to drop it before going ahead to provision it. I found dx_get_db_env as part of the delphix toolkit but that returns all the VDBs. How can I check for one VDB so that I can either get a 0 or a 1 return and based on that I can provision / remove and then provision the VDB.

Thanks.
Photo of Srividya Srinivasan

Srividya Srinivasan

  • 304 Points 250 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Ranzo Taylor

Ranzo Taylor, Employee

  • 1,572 Points 1k badge 2x thumb
One advantage of dxtoolkit is that you can pipe the output to other UNIX commands.  Try the following:

dx_get_db_env | grep VDB_NAME
echo $?

The grep command returns a "0" if it find a match for a regular expression (in this case, the VDB_NAME you are looking for.  You query the return code of the last command in UNIX with the special string "$?".

If $? equals 0, you have the VDB_NAME already.  If it's 1, you don't.