Sun Java logo     Previous      Contents      Index      Next     

Sun logo
Sun ONE Directory Server Resource Kit 5.2 Tools Reference 

Chapter 22
The LDIF Merge Tool

The mmldif tool combines multiple LDIF (LDAP Data Interchange Format) files into a single directory hierarchy. The result is the union of all input files. This chapter provides instructions on how to use the mmldif tool. It contains the following sections:


Overview

The mmldif tool merges multiple LDIF files into a single directory hierarchy. The result is one output file, containing any entry whose DN appears in one or more of the input files. In a typical usage scenario, mmldif can be used to create an authoritative database for servers cooperating in a multi-master replication agreement. If for some reason all masters are no longer able to synchronize, the mmldif tool can be used to generate the master database manually.


Command Usage

The mmldif tool unites all input files, based on the DNs they contain: entries that exist in one or more input files are added to the hierarchy of the final output. When the same DN appears in multiple files, the tool will verify that all attribute values are identical. If the attribute values differ, the conflict is resolved by choosing the entry with the most recent time stamp. The time stamp is defined by one of the following attributes: modifyTimestamp, createTimestamp, or deleteTimestamp. mmldif also recognizes deleted entries by the objectclass: nsTombstone attribute and handles them accordingly. For LDIF files to contain these special attributes, you must use the db2ldif -r option when extracting the entries from your directories. For more information, see “db2ldif (Export Database Contents to LDIF)” in Chapter 2 of the Sun ONE Directory Server Reference Manual.

Syntax

The syntax of the mmldif tool on the command-line takes the following form:

mmldif [-c] [-o output.ldif] input1.ldif input2.ldif ...

Where:

Options

The mmldif options and parameters are described in Table 22-1. The mmldif -h command will display a usage help text that briefly describes all options.

Table 22-1  Command-Line Options for mmldif 

Option

Parameter

Purpose

-o

outputFile

Specify the output file for the merge of all LDIF inputs. The output file is itself a complete directory hierarchy in LDIF text. When this parameter is omitted, the mmldif tool produces no output and reports only the number of differences between the input files.

-c

 

Write a change file containing LDIF update statements for each input file. The change file will have the same path and filename as the corresponding input file, with the addition of the suffix .delta. When using this option, the input files must be in a writable location. Old change files for the same input will be overwritten.

-h

 

Display the usage help text that briefly describes all options.


Command-Line Examples

The examples in this section demonstrate different types of output from the mmldif tool. They use as input two LDIF files: one.ldif and two.ldif. Both files are reproduced in Table 22-2 with the differences between the two formatted in bold.

Table 22-2  one.ldif And two.ldif Input Files

Filename: one.ldif

Filename: two.ldif

dn: sn=Jensen,dc=siroe,dc=com
objectclass: top
objectclass: person
cn: Babs Jensen
sn: Jensen
telephoneNumber: 555-5550
createTimestamp: 100

dn: sn=Minsky,dc=siroe,dc=com
objectclass: top
objectclass: person
cn: Pete Minsky
sn: Minsky
telephoneNumber: 555-5551
createTimestamp: 100

dn: sn=Rose,dc=siroe,dc=com
objectclass: top
objectclass: person
cn: Paula Rose
sn: Rose
telephoneNumber: 555-5552
createTimestamp: 100

dn: sn=Jensen,dc=siroe,dc=com
objectclass: top
objectclass: person
cn: Babs Jensen
sn: Jensen
telephoneNumber: 555-5550
createTimestamp: 100

dn: sn=Minsky,dc=siroe,dc=com
objectclass: top
objectclass: person
cn: Pete Minsky
sn: Minsky
telephoneNumber: 555-5559
modifyTimestamp: 200

dn: sn=Morris,dc=siroe,dc=com
objectclass: top
objectclass: person
cn: Ted Morris
sn: Morris
telephoneNumber: 555-5558
createTimestamp: 200

dn: sn=Rose,dc=siroe,dc=com
objectclass: nsTombstone
deleteTimestamp: 200

Merge Statistics

The mmldif tool always displays merge statistics to the standard output. The -o outputFile parameter may be omitted when you are interested only in the number of differences between input files as in this command:

$ mmldif one.ldif two.ldif

The output reproduced inCode Example 22-1 confirms the differences between the two input files.

Code Example 22-1  Merge Statistics Output

start time Wed Jul 11 12:34:56 2001

entry counts: unchanged=1 changed=2 new=1 total=4

end time Wed Jul 11 12:34:56 2001

differencing took <= 1 second

By inspecting the LDIF files in Table 22-2, we can see the following (also detailed in Code Example 22-1):

Merge Output File

Running the command detailed in Merge Statistics with the -o outputFile parameter will allow us to see the result of the merge.

$ mmldif -o merge.ldif one.ldif two.ldif

The output reproduced inCode Example 22-2 details the result of the union between the two input files.

Produce Change Files

To see how each input relates to the merge result, mmldif can generate change files. Change files contain LDIF update statements that represent the difference between the corresponding input and the merged result. Applying the change file to the directory of the corresponding input will make the directory contents equivalent to the contents of the merged result. To do this, the change file can be used as input to the ldapmodify command. (See Chapter 4, "The ldapmodify Tool" for more information.) LDIF update statements showing the difference between each input file and merge result can be generated by running the following command:

$ mmldif -o merge.ldif -c one.ldif two.ldif

The output reproduced inCode Example 22-3 details the changes between the two input files.

Code Example 22-3  Output of Changes

start time Wed Jul 11 12:34:56 2001

entry counts: unchanged=1 changed=2 new=1 total=4

end time Wed Jul 11 12:34:56 2001

differencing took <= 1 second

Code Example 22-4 shows how to bring the contents of one.ldif up to date with the result of the merge. The changes detailed are:

In addition to one.ldif.delta, the file two.ldif.delta is also generated but it is empty (zero length) because two.ldif contains all of the most recent modifications between the two input files.

Code Example 22-4  one.ldif.delta 

$ cat one.ldif.delta

dn: sn=Minsky,dc=siroe,dc=com

changetype: modify

delete: createTimestamp

-

replace: telephoneNumber

telephoneNumber: 555-5559

-

dn: sn=Rose,dc=siroe,dc=com

changetype: delete

dn: sn=Morris,dc=siroe,dc=com

changetype: add

cn: Ted Morris

createTimestamp: 200

objectclass: person

objectclass: top

sn: Morris

telephoneNumber: 555-5558

Supposing that one.ldif represents the contents the directory on host one, port 389, the following command will update those contents so that they are equivalent to merge.ldif:

$ ldapmodify -h one -D "bindDN" -w bindPassword \
             -f one.ldif.delta

This command uses the credentials of the bindDN to access the directory and assumes that user has permission to modify entries. See Chapter 4, "The ldapmodify Tool," for more information.



Previous      Contents      Index      Next     


Copyright 2004 Sun Microsystems, Inc. All rights reserved.