1.12.バックアップと復元
これで、LDAP が希望どおりに実行できるようになりました。次は、すべての作業を保存し、必要に応じて復元できることを確認します。
必要なのは、LDAP データベース、特にバックエンド (cn=config) とフロントエンド (dc=example,dc=com) をバックアップする方法です。 これらのデータベースを次のようにバックアップする場合、 /エクスポート/バックアップ、次のスクリプトに示すように、slapcat を使用できます。 /usr/local/bin/ldapbackup:
#!/ bin / bashに
BACKUP_PATH=/エクスポート/バックアップ SLAPCAT=/usr/sbin/slapcat
素晴らしい ${SLAPCAT} -n 0 > ${BACKUP_PATH}/config.ldif
nice ${SLAPCAT} -n 1 > ${BACKUP_PATH}/example.com.ldif nice ${SLAPCAT} -n 2 > ${BACKUP_PATH}/access.ldif chmod 640 ${BACKUP_PATH}/*.ldif
これらのファイルは、ツリー レイアウト、ユーザー名、すべてのパスワードを含む LDAP データベース内のすべての情報を含む非圧縮テキスト ファイルです。 したがって、作成することを検討するとよいでしょう。 /エクスポート/バックアップ 暗号化されたパーティションを作成し、スクリプトがそれらのファイルを作成するときにそれらのファイルを暗号化することもできます。
理想的には両方を行う必要がありますが、それはセキュリティ要件によって異なります。
あとは、このプログラムを必要なだけ実行する cron スクリプトを用意するだけです。 多くの人にとって、XNUMX 日 XNUMX 回で十分です。 他の場合には、より頻繁に必要になります。 以下は、cron スクリプトの例です。 /etc/ cron.d/ldapbackup これは毎晩 22:45 に実行されます。
45 22 * * * ルート /usr/local/bin/ldapbackup
ファイルが作成されたので、バックアップ サーバーにコピーする必要があります。
LDAP を新たに再インストールしたと仮定すると、復元プロセスは次のようになります。
19 http://manpages.ubuntu.com/manpages/en/man1/ldapmodifygroup.1.html
20 http://manpages.ubuntu.com/manpages/en/man1/ldapdeletemachine.1.html
21 http://manpages.ubuntu.com/manpages/en/man1/ldaprenamegroup.1.html
22 http://manpages.ubuntu.com/manpages/en/man1/ldapaddmachine.1.html
23 http://manpages.ubuntu.com/manpages/en/man1/ldapmodifymachine.1.html
24 http://manpages.ubuntu.com/manpages/en/man1/ldapsetprimarygroup.1.html
25 http://manpages.ubuntu.com/manpages/en/man1/ldapdeleteuser.1.html
sudo systemctl stop stopd.service sudo mkdir /var/lib/ldap/accesslog
sudoslapadd -F /etc/ldap/slapd.d -n 0 -l /export/backup/config.ldif sudo sawadd -F /etc/ldap/slapd.d -n 1 -l /export/backup/domain.com .ldif sudo sawadd -F /etc/ldap/slapd.d -n 2 -l /export/backup/access.ldif sudo chown -R openldap:openldap /etc/ldap/slapd.d/
sudo chown -R openldap:openldap /var/lib/ldap/ sudo systemctl start stopd.service