Backing Up & Restoring Data
OpenDJ lets you backup and restore your data either in compressed,
binary format, or in LDAP Data Interchange Format. This chapter shows you how
to backup and to restore OpenDJ data from archives, and explains portability
of backup archives, as well as backing up server configuration
information.
Backing Up Directory Data
Backup
A bak/ directory is provided when you install
OpenDJ, as a location to save binary backups. When you create a backup,
the bak/backup.info contains information about the
archive.
Archives produced by the backup command contain
backups only of the directory data. Backups of server configuration are
found in config/archived-configs/.
To Back Up Data Immediately
Use one of the following alternatives.
Back up only the database for Example.com, where the data
is stored in the backend named userRoot.
$ backup
--port 5444
--bindDN "cn=Directory Manager"
--bindPassword password
--backendID userRoot
--backupDirectory /path/to/OpenDJ/bak
--start 0
Backup task 20110613143715983 scheduled to start Jun 13, 2011 2:37:15 PM CEST
Stop the server to back up Example.com data offline.
$ stop-ds
Stopping Server...
[13/Jun/2011:14:31:00 +0200] category=BACKEND severity=NOTICE msgID=9896306
msg=The backend userRoot is now taken offline
[13/Jun/2011:14:31:00 +0200] category=CORE severity=NOTICE msgID=458955
msg=The Directory Server is now stopped
$ backup --backendID userRoot -d /path/to/OpenDJ/bak
[13/Jun/2011:14:33:48 +0200] category=TOOLS severity=NOTICE msgID=10944792
msg=Starting backup for backend userRoot
[13/Jun/2011:14:33:48 +0200] category=JEB severity=NOTICE msgID=8847446
msg=Archived: 00000000.jdb
[13/Jun/2011:14:33:48 +0200] category=TOOLS severity=NOTICE msgID=10944795
msg=The backup process completed successfully
$ start-ds
... The Directory Server has started successfully
Back up all user data on the server.
$ backup
--port 5444
--bindDN "cn=Directory Manager"
--bindPassword password
--backUpAll
--backupDirectory /path/to/OpenDJ/bak
--start 0
Backup task 20110613143801866 scheduled to start Jun 13, 2011 2:38:01 PM CEST
To Schedule Data Backup
You can schedule data backup using crontab
format.
Back up all user data every night at 2 AM, and notify
diradmin@example.com when finished, or on error.
$ backup
--port 5444
--bindDN "cn=Directory Manager"
--bindPassword password
--backUpAll
--backupDirectory /path/to/OpenDJ/bak
--recurringTask "00 02 * * *"
--completionNotify diradmin@example.com
--errorNotify diradmin@example.com
Recurring Backup task BackupTask-988d6adf-4d65-44bf-8546-6ea74a2480b0
scheduled successfully
Restoring Directory Data From Backup
Backup
Restoring
From backup
When you restore data, the procedure to follow depends on whether
the OpenDJ directory server is replicated.
To Restore a Stand-alone Server
Use one of the following alternatives.
Stop the server to restore data for Example.com.
$ stop-ds
Stopping Server...
[13/Jun/2011:15:44:06 +0200] category=BACKEND severity=NOTICE msgID=9896306
msg=The backend userRoot is now taken offline
[13/Jun/2011:15:44:06 +0200] category=CORE severity=NOTICE msgID=458955
msg=The Directory Server is now stopped
$ restore --backupDirectory /path/to/OpenDJ/bak --listBackups
Backup ID: 20110613080032
Backup Date: 13/Jun/2011:08:00:45 +0200
Is Incremental: false
Is Compressed: false
Is Encrypted: false
Has Unsigned Hash: false
Has Signed Hash: false
Dependent Upon: none
$ restore --backupDirectory /path/to/OpenDJ/bak --backupID 20110613080032
[13/Jun/2011:15:47:41 +0200] category=JEB severity=NOTICE msgID=8847445
msg=Restored: 00000000.jdb (size 341835)
$ start-ds
... The Directory Server has started successfully
Schedule the restore as a task to begin immediately.
$ restore
--port 5444
--bindDN "cn=Directory Manager"
--bindPassword password
--backupDirectory /path/to/OpenDJ/bak
--backupID 20110613080032
--start 0
Restore task 20110613155052932 scheduled to start Jun 13, 2011 3:50:52 PM CEST
To Restore a Replica
Replication
Restoring from backup
When you restore a replicated server from backup, make sure the
backup is newer than the last purge of the replication change log (default:
3 days).
Prepare the replica to be restored.
$ dsreplication
pre-external-initialization
--adminUID admin
--adminPassword password
--trustAll --no-prompt
--port 5444
--baseDN dc=example,dc=com
Preparing base DN dc=example,dc=com to be initialized externally ..... Done.
Now you can proceed to the initialization of the contents of the base DN's
on all the replicated servers. You can use the command import-ldif or
the binary copy to do so. You must use the same LDIF file or binary copy
on each server.
When the initialization is completed you must use the subcommand
'post-external-initialization' for replication to work with the new
base DN's contents.
Restore the server database from the backup archive.
$ stop-ds
Stopping Server...
[13/Jun/2011:15:44:06 +0200] category=BACKEND severity=NOTICE msgID=9896306
msg=The backend userRoot is now taken offline
[13/Jun/2011:15:44:06 +0200] category=CORE severity=NOTICE msgID=458955
msg=The Directory Server is now stopped
$ restore --backupDirectory /path/to/OpenDJ/bak --listBackups
Backup ID: 20110613080032
Backup Date: 13/Jun/2011:08:00:45 +0200
Is Incremental: false
Is Compressed: false
Is Encrypted: false
Has Unsigned Hash: false
Has Signed Hash: false
Dependent Upon: none
$ restore --backupDirectory /path/to/OpenDJ/bak --backupID 20110613080032
[13/Jun/2011:15:47:41 +0200] category=JEB severity=NOTICE msgID=8847445
msg=Restored: 00000000.jdb (size 341835)
$ start-ds
... The Directory Server has started successfully
Reinitialize replication on the replica.
$ dsreplication
post-external-initialization
--adminUID admin
--adminPassword password
--port 5444
--baseDN dc=example,dc=com
--trustAll
--no-prompt
Updating replication information on base DN dc=example,dc=com ..... Done.
Post initialization procedure completed successfully.