Probably the best way is to put all your initialization in a function and then call it once with each instance. Something like:
function initChart(chart) {
chart.dimension(...)
.group(...)
...
;
}
var chart1 = dc.barChart("#id1"), chart2 = dc.barChart("#id1");
initChart(chart1);
initChart(chart2);
Keep in mind that if you use the same dimension they will not filter each other, so you may want to do that part separately, depending on your app.