anchor.diff:  title: Connecting BOSH or MicroBOSH to an External Postgres Database
   ---
   
  -The BOSH Director or MicroBOSH Director stores deployed VM status information in an internal or an external database. An internal database might be sufficient for your deployment; however, a highly-available external database can improve performance and scalability and protect against data loss. 
  +The BOSH Director or MicroBOSH Director stores deployed VM status information in an internal or an external database. An internal database might be sufficient for your deployment; however, a highly-available external database can improve performance and scalability and protect against data loss.
   
   This topic describes how to connect BOSH or MicroBOSH to a highly-available external Postgres database.
  - 
  - 
  +
  +
   ##<a id="bosh"></a>BOSH ##
   
   BOSH requires that the BOSH deployment manifest contains database configuration information. By default, the manifest includes a pre-configured `postgres` sub-block that connects BOSH to an internal Postgres database. To configure BOSH to use an external Postgres database, modify the manifest with your external database connection information and redeploy.
  
positive.code: 
  1. Record the hostname and port number of your Postgres database.
  1. Open your BOSH deployment manifest in a text editor.
  1. Locate and modify the `postgres` sub-block in the `properties` block. 
  
      Replace the existing user credentials, database host, and port number with your Postgres database connection information. Add the port number key/value pair if it does not exist.
  
      <pre class="terminal">
    properties:
       postgres: &amp;bosh&#95;db
         adapter: postgres
         user: USER&#95;NAME 
         password: PASSWORD 
         host: HOST&#95;NAME 
         port: PORT&#95;NUMBER
         database: bosh
     </pre>
  
  1. Redeploy.
  
  
  ##<a id="microbosh"></a>MicroBOSH  
  
  MicroBOSH does not require that you specify a database in the deployment manifest. If you do not specify a database, MicroBOSH uses an internal Postgres database. To configure MicroBOSH to use an external Postgres database, add a `postgres` sub-block to your deployment manifest and redeploy.
  
  
negative.code: 1. Open your MicroBOSH deployment manifest in a text editor and locate the `properties` sub-block in the `apply_spec` block.
  1. Add the `postgres` sub-block to the `properties` sub-block.
  
      Replace the user credentials, database host, and port number with your Postgres database connection information.
  
      <pre class="terminal">
  apply&#95;spec:
  ...
    properties:
        postgres: &#38;bosh&#95;db
            adapter: postgres
            user: USER&#95;NAME
            password: PASSWORD
            host: HOST&#95;NAME
            port: PORT&#95;NUMBER
            database: bosh
      </pre>
  
  1. In the `director` sub-block and the `dns` sub-block of the `properties` sub-block, add a pointer to the postgres database.
  
      <pre class="terminal">
  apply&#95;spec:
  ...
    properties:
    ...
        director:
           db: &#42;bosh&#95;db
    ...
        dns:
            db: &#42;bosh&#95;db
    ...
      </pre>
  
  1. Redeploy.