We consider the problem of guaranteeing that the transient voltages and currents stay within prescribed bounds in Direct Current (DC) microgrids, when the controller does not have access to accurate system dynamics due to the load being unknown and/or time-varying. To achieve this, we propose an optimization based controller design using control barrier functions. We show that the proposed controller has a decentralized structure and is robust with respect to the uncertainty in the precise values of the system parameters, such as the load.