How to update startup-config after each commit?

In my daemon, I was starting session to CDB_RUNNING with flag as 0 whenever user commits configuration. But when I do ‘copy running-config startup-config’, I still see startup-config has default values that I initialized rather than the changed values. Am I missing something or if I need to do anything extra to update the startup-config?

Let’s go with a concrete example to see how to work with the startup datastore. I will go with the intro/1-2-3 example.

First, I have modified the confd.conf file to enable the startup datastore. Following are the changes as compared to the one in the original example:

$ diff confd.conf ../1-2-3-start-query-model/confd.conf
163c163
<       <enabled>true</enabled>
---
>       <enabled>false</enabled>
230c230
<     <enabled>true</enabled>
---
>     <enabled>false</enabled>

Following is a list of NETCONF operations through netconf-console that illustrates how to copy the contents of running to startup after a config leaf value has changed in running:

$ netconf-console --get-config --db running -x dhcp
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data/>
</rpc-reply>
$ netconf-console cmd-set-dhcp-defaultLeaseTime-30m.xml 
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <ok/>
</rpc-reply>
$ netconf-console --get-config --db running -x dhcp
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <dhcp xmlns="http://tail-f.com/ns/example/dhcpd">
      <defaultLeaseTime>PT30M</defaultLeaseTime>
    </dhcp>
  </data>
</rpc-reply>
$ netconf-console --get-config --db startup -x dhcp
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data/>
</rpc-reply>
$ netconf-console --copy-running-to-startup
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <ok/>
</rpc-reply>
$ netconf-console --get-config --db startup -x dhcp
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <dhcp xmlns="http://tail-f.com/ns/example/dhcpd">
      <defaultLeaseTime>PT30M</defaultLeaseTime>
    </dhcp>
  </data>
</rpc-reply>