117-301 · Question #104
When two databases are defined in slapd.conf, which of the following commands will provide a full dump of the second database?
The correct answer is A. slapcat -n 2. See the full explanation below for the reasoning.
Question
Options
- Aslapcat -n 2
- Bslapcat -2
- Cslapcat -database 2
- Dslap_dumpall -name nameofdatabase
How the community answered
(33 responses)- A82% (27)
- B12% (4)
- C3% (1)
- D3% (1)
Community Discussion
7Answer is A, slapcat -n 2. The -n flag selects the database by index number, and the indexing in OpenLDAP starts at 0 for the implicit frontend/config database, so the first explicitly defined database in slapd.conf is index 1 and the second is index 2. Check man slapcat section OPTIONS, the -n dbnum entry spells this out directly. Options B and C are fabricated syntax that slapcat does not recognize, and slap_dumpall in option D is not a real command on any OpenLDAP system you will ever touch.
Saw this exact scenario on mine, they worded it as "second database defined in slapd.conf" and I almost second-guessed myself into B because it looked cleaner, but the -n flag is the right switch for specifying the database number so A is the one. Slapcat -n 2 gets you that full LDIF dump of the second database, no tricks to it.
I almost went with C thinking slapcat took a long-form flag like -database, but then I remembered that slapcat uses -n to select the database by its zero-based or sequential index in slapd.conf, and -n 2 targets the second database definition, which locks in A as the only valid syntax here.
Burned this one on my first practice run, the -n flag is everything.
The -n flag saves you from those silent clobbers, but pair it with a test run using echo cp to see exactly what rsync would touch before you commit to anything.
I remember freezing on this one for a second because I kept confusing the -n flag with verbose levels from other tools, but the slapcat man page is clear: -n selects the database by number in the order they appear in slapd.conf, so -n 2 dumps the second database. Saw two or three people in my study group lose points on this because they guessed -database 2 thinking it followed a GNU long-option style, but that flag simply does not exist.
Worth adding for anyone drilling 202-450 objective 210.3: the safer habit on exam scenarios and in production is pairing your slapcat run with the -b flag and the actual suffix, because counting database positions in slapd.conf is fragile the moment someone inserts a new database entry above yours and your -n 2 now points somewhere unexpected.