Bug 1447015

Summary: Adjust db2bak.pl help and man page to reflect changes introduced to the script
Product: Red Hat Enterprise Linux 7 Reporter: Simon Reber <sreber>
Component: 389-ds-baseAssignee: mreynolds
Status: CLOSED ERRATA QA Contact: Viktor Ashirov <vashirov>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: amsharma, lmiksik, nkinder, rmeggins, roman.aleksic
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 389-ds-base-1.3.6.1-16.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 21:16:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Simon Reber 2017-05-01 07:24:42 UTC
Description of problem:

In Red Hat Enterprise Linux 7, the db2bak.pl script has been changed according to https://pagure.io/389-ds-base/c/8db3a1ad07198ba548f653aa4acebe4324c16384, to always write the backup to `/var/lib/dirsrv/<instance>/bak` and simply create a symlink for the location specified with `-a` or `-A`

The current usage description of the script does not really indicate that the backup won't be written to the designated location:

- https://pagure.io/389-ds-base/blob/master/f/ldap/admin/src/scripts/db2bak.pl.in#_36

From the given description, one would assume that the backup is written to the location specified with `-a` or `-A` and not just a symlink created to the default location.

This can cause various issues, as customers may not expect the backup to be written to this location and it therefore can fill up the volume badly.

It's therefore required to adjust the usage output and man page of the script to reflect that change and help the customer understand how this works.

Version-Release number of selected component (if applicable):

 - 389-ds-base-1.3.5.10-15.el7_3.x86_64

How reproducible:

 - Always

Steps to Reproduce:
1. db2bak.pl -a /mnt/backup -D 'cn=directory manager' -w -
2. Check if the Backup was written to `/mnt/backup` or just a symlink created to  `/var/lib/dirsrv/<instance>/bak`

Actual results:

Symlink created to `/var/lib/dirsrv/<instance>/bak`

Expected results:

Backup created in `/mnt/backup` or else an updated usage of the script as well as man page

Additional info:

Comment 2 mreynolds 2017-05-03 20:07:40 UTC
The man page and script usage needs to be updated to express this behavior

Comment 3 mreynolds 2017-05-03 20:08:53 UTC
Upstream ticket:
https://pagure.io/389-ds-base/issue/49241

Comment 5 Amita Sharma 2017-05-17 08:44:09 UTC
This needs some minor fixes -

1). Commit message fix -> https://pagure.io/389-ds-base/c/470a30c - commit message = * state thtthe backup *

2). Synopsis in man page need correction, it still says backupdir for -a and -A

NAME
       db2bak.pl - Directory Server perl script for creating a backup

SYNOPSIS
       db2bak.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename }  [-t dbtype] [-a backupdir] [-A backupdir] [-P protocol]
       [-h]

3). This is correct
      -a backupdir
              The  directory  where  the  backup should be stored.  This directory is a symbolic link to the actual backup files located
              under "nsslapd-bakdir" directory that is set in the "cn=config" entry.

       -A backupdir
              This is similar to -a, except that a sub-directory of backupdir will be created for the backup, and the name of  the  sub-
              directory will be a timestamp of the form server-instance-date_time.

4). we removed -v option? I can still see the option in help though but it does not work.
[0 root@qeos-41 /]# db2bak.pl -v -D "cn=Directory Manager" -w Secret123 -a "/export/backup/data.ldif"
ERROR - Unknown option: -v
Usage: db2bak.pl [-v] [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } [-a backupdir]
                 [-t dbtype] [-P protocol] [-h]

5). Can we change the output here as "symbolic link to backup directory" instead of just "Back up directory"
[0 root@qeos-41 /]# db2bak.pl -D "cn=Directory Manager" -w Secret123 -a "/export/backup/data.ldif"
Back up directory: /export/backup/data.ldif
Successfully added task entry "cn=backup_2017_5_17_4_38_34, cn=backup, cn=tasks, cn=config"

6). This works fine
nsslapd-bakdir: /var/lib/dirsrv/slapd-qeos-41/bak
[0 root@qeos-41 /]# cd /export/backup/
[0 root@qeos-41 backup]# ls -al
total 8
drwxr-xr-x. 2 root   root   4096 May 17 04:38 .
drwxr-xr-x. 5 dirsrv dirsrv 4096 May 17 03:52 ..
lrwxrwxrwx. 1 root   root     43 May 17 04:38 data.ldif -> /var/lib/dirsrv/slapd-qeos-41/bak/data.ldif

Thanks.

Comment 6 mreynolds 2017-05-24 16:13:25 UTC
(In reply to Amita Sharma from comment #5)
> This needs some minor fixes -
> 
> 1). Commit message fix -> https://pagure.io/389-ds-base/c/470a30c - commit
> message = * state thtthe backup *
> 
> 2). Synopsis in man page need correction, it still says backupdir for -a and
> -A

I think this should not change - that's what the option description is for - to describe what it does.  I just think it might be confusing if we change: backupdir to symbackupdir.  

 
> 
> NAME
>        db2bak.pl - Directory Server perl script for creating a backup
> 
> SYNOPSIS
>        db2bak.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j
> filename }  [-t dbtype] [-a backupdir] [-A backupdir] [-P protocol]
>        [-h]
> 
> 3). This is correct
>       -a backupdir
>               The  directory  where  the  backup should be stored.  This
> directory is a symbolic link to the actual backup files located
>               under "nsslapd-bakdir" directory that is set in the
> "cn=config" entry.
> 
>        -A backupdir
>               This is similar to -a, except that a sub-directory of
> backupdir will be created for the backup, and the name of  the  sub-
>               directory will be a timestamp of the form
> server-instance-date_time.
> 
> 4). we removed -v option? I can still see the option in help though but it
> does not work.
> [0 root@qeos-41 /]# db2bak.pl -v -D "cn=Directory Manager" -w Secret123 -a
> "/export/backup/data.ldif"
> ERROR - Unknown option: -v
> Usage: db2bak.pl [-v] [-Z serverID] [-D rootdn] { -w password | -w - | -j
> filename } [-a backupdir]
>                  [-t dbtype] [-P protocol] [-h]
> 
> 5). Can we change the output here as "symbolic link to backup directory"
> instead of just "Back up directory"

I'm proposing this approach in my patch:

# db2bak.pl -w password -D cn=dm -a /tmp/mark
Back up directory: /tmp/mark -> /var/lib/dirsrv/slapd-localhost/bak/mark
...

> [0 root@qeos-41 /]# db2bak.pl -D "cn=Directory Manager" -w Secret123 -a
> "/export/backup/data.ldif"
> Back up directory: /export/backup/data.ldif
> Successfully added task entry "cn=backup_2017_5_17_4_38_34, cn=backup,
> cn=tasks, cn=config"
> 
> 6). This works fine
> nsslapd-bakdir: /var/lib/dirsrv/slapd-qeos-41/bak
> [0 root@qeos-41 /]# cd /export/backup/
> [0 root@qeos-41 backup]# ls -al
> total 8
> drwxr-xr-x. 2 root   root   4096 May 17 04:38 .
> drwxr-xr-x. 5 dirsrv dirsrv 4096 May 17 03:52 ..
> lrwxrwxrwx. 1 root   root     43 May 17 04:38 data.ldif ->
> /var/lib/dirsrv/slapd-qeos-41/bak/data.ldif
> 
> Thanks.

Comment 7 Amita Sharma 2017-05-25 07:13:57 UTC
(In reply to mreynolds from comment #6)
> (In reply to Amita Sharma from comment #5)
> > This needs some minor fixes -
> > 
> > 1). Commit message fix -> https://pagure.io/389-ds-base/c/470a30c - commit
> > message = * state thtthe backup *
> > 
> > 2). Synopsis in man page need correction, it still says backupdir for -a and
> > -A
> 
> I think this should not change - that's what the option description is for -
> to describe what it does.  I just think it might be confusing if we change:
> backupdir to symbackupdir.  
Ok.
> 
>  
> > 
> > NAME
> >        db2bak.pl - Directory Server perl script for creating a backup
> > 
> > SYNOPSIS
> >        db2bak.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j
> > filename }  [-t dbtype] [-a backupdir] [-A backupdir] [-P protocol]
> >        [-h]
> > 
> > 3). This is correct
> >       -a backupdir
> >               The  directory  where  the  backup should be stored.  This
> > directory is a symbolic link to the actual backup files located
> >               under "nsslapd-bakdir" directory that is set in the
> > "cn=config" entry.
> > 
> >        -A backupdir
> >               This is similar to -a, except that a sub-directory of
> > backupdir will be created for the backup, and the name of  the  sub-
> >               directory will be a timestamp of the form
> > server-instance-date_time.
> > 
> > 4). we removed -v option? I can still see the option in help though but it
> > does not work.
> > [0 root@qeos-41 /]# db2bak.pl -v -D "cn=Directory Manager" -w Secret123 -a
> > "/export/backup/data.ldif"
> > ERROR - Unknown option: -v
> > Usage: db2bak.pl [-v] [-Z serverID] [-D rootdn] { -w password | -w - | -j
> > filename } [-a backupdir]
> >                  [-t dbtype] [-P protocol] [-h]
> > 
> > 5). Can we change the output here as "symbolic link to backup directory"
> > instead of just "Back up directory"
> 
> I'm proposing this approach in my patch:
> 
> # db2bak.pl -w password -D cn=dm -a /tmp/mark
> Back up directory: /tmp/mark -> /var/lib/dirsrv/slapd-localhost/bak/mark
> ...
Even better, Sounds good to me, .
> 
> > [0 root@qeos-41 /]# db2bak.pl -D "cn=Directory Manager" -w Secret123 -a
> > "/export/backup/data.ldif"
> > Back up directory: /export/backup/data.ldif
> > Successfully added task entry "cn=backup_2017_5_17_4_38_34, cn=backup,
> > cn=tasks, cn=config"
> > 
> > 6). This works fine
> > nsslapd-bakdir: /var/lib/dirsrv/slapd-qeos-41/bak
> > [0 root@qeos-41 /]# cd /export/backup/
> > [0 root@qeos-41 backup]# ls -al
> > total 8
> > drwxr-xr-x. 2 root   root   4096 May 17 04:38 .
> > drwxr-xr-x. 5 dirsrv dirsrv 4096 May 17 03:52 ..
> > lrwxrwxrwx. 1 root   root     43 May 17 04:38 data.ldif ->
> > /var/lib/dirsrv/slapd-qeos-41/bak/data.ldif
> > 
> > Thanks.

Thanks.

Comment 8 mreynolds 2017-05-25 14:05:20 UTC
Thanks Amita, fixed upstream

Comment 10 Amita Sharma 2017-06-12 11:14:20 UTC
[root@qeos-213 upstream]# db2bak.pl -v -D "cn=Directory Manager" -w Secret123 -a "/export/backup/data.ldif"
ERROR - Unknown option: -v
Usage: db2bak.pl [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } [-a backupdir]
                 [-t dbtype] [-P protocol] [-h]
Options:
        -D rootdn     - Directory Manager
        -w password   - Directory Manager's password
        -w -          - Prompt for Directory Manager's password
        -Z serverID   - Server instance identifier
        -j filename   - Read Directory Manager's password from file
        -A backupdir  - Backup directory symlink(backupdir/ID-<date_time>)
        -a backupdir  - Backup directory symlink
        -t dbtype     - Database type (default: ldbm database)
        -P protocol   - STARTTLS, LDAPS, LDAPI, LDAP (default: uses most secure protocol available)
        -h            - Display usage

---------------------------


[root@qeos-213 backup2]# db2bak.pl -D "cn=Directory Manager" -w Secret123 -a "/export/backup2/data.ldif" 
Back up directory: /export/backup2/data.ldif -> /var/lib/dirsrv/slapd-qeos-213/bak/data.ldif
Successfully added task entry "cn=backup_2017_6_12_7_13_18, cn=backup, cn=tasks, cn=config"

[root@qeos-213 backup2]# ls -al
total 0
drwxr-xr-x. 2 dirsrv dirsrv  40 Jun 12 07:13 .
drwxr-xr-x. 7 dirsrv dirsrv 101 Jun 12 06:48 ..
-rw-r--r--. 1 root   root     0 Jun 12 07:12 data,ldif
lrwxrwxrwx. 1 root   root    44 Jun 12 07:13 data.ldif -> /var/lib/dirsrv/slapd-qeos-213/bak/data.ldif

Comment 11 errata-xmlrpc 2017-08-01 21:16:38 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2086