Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-14 Thread Martin Kosek
On 01/13/2015 06:02 PM, Jan Cholasta wrote:
 Dne 13.1.2015 v 17:45 Jan Cholasta napsal(a):
 Dne 13.1.2015 v 16:37 Petr Vobornik napsal(a):
 On 01/13/2015 02:26 PM, Jan Cholasta wrote:
 Dne 13.1.2015 v 13:01 Petr Vobornik napsal(a):
 On 01/12/2015 02:28 PM, Jan Cholasta wrote:
 Hi,

 the attached patch fixes
 https://fedorahosted.org/freeipa/ticket/4797.

 Note that --data with data-only backup and --logs-only with data-only
 restore are deliberately ignored and considered no-op.

 Honza



 3. When #2 fixed, data backup with --no-logs doesn't raise warning as
 requested in ticket.

 IMO such a warning does not make sense. You request no logs, you get no
 logs, I don't see anything worth warning about here.

 ok, makes sense



 5. Nitpick: imho option validation should be done before temp dir
 creation.

 Fixed.

 You've also moved
self.header = os.path.join(self.backup_dir, 'header')
 below
self.read_header()

 -- restore fails everytime

 Silly me. Sorry. Fixed.

 Rebased updated patch attached.
 
 Rebased again, patch attached.

Given that Petr is not there today, I finished the review for him. I did not
find any other issues, all issues except (2) are fixed.

ACK. Pushed to master (rebased) and ipa-4-1.

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-14 Thread Petr Viktorin

On 01/14/2015 09:14 AM, Martin Kosek wrote:

On 01/13/2015 06:02 PM, Jan Cholasta wrote:



Rebased again, patch attached.


Given that Petr is not there today, I finished the review for him. I did not
find any other issues, all issues except (2) are fixed.

ACK. Pushed to master (rebased) and ipa-4-1.


This broke master.

* Module ipaserver.install.ipa_restore
ipaserver/install/ipa_restore.py:175: [E0602(undefined-variable), 
Restore.validate_options] Undefined variable 'BACKUP_DIR')
ipaserver/install/ipa_restore.py:210: [E0602(undefined-variable), 
Restore.run] Undefined variable 'BACKUP_DIR')


--
PetrĀ³

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-14 Thread Martin Kosek
On 01/14/2015 12:35 PM, Petr Viktorin wrote:
 On 01/14/2015 09:14 AM, Martin Kosek wrote:
 On 01/13/2015 06:02 PM, Jan Cholasta wrote:
 
 Rebased again, patch attached.

 Given that Petr is not there today, I finished the review for him. I did not
 find any other issues, all issues except (2) are fixed.

 ACK. Pushed to master (rebased) and ipa-4-1.
 
 This broke master.
 
 * Module ipaserver.install.ipa_restore
 ipaserver/install/ipa_restore.py:175: [E0602(undefined-variable),
 Restore.validate_options] Undefined variable 'BACKUP_DIR')
 ipaserver/install/ipa_restore.py:210: [E0602(undefined-variable), Restore.run]
 Undefined variable 'BACKUP_DIR')
 

Grr... Sorry for the hickup, I fixed it with the attached patch and pushed it
to master as a one liner.
From 35c4fa2e36a83ad80c79a21ac8e495985f38dbde Mon Sep 17 00:00:00 2001
From: Martin Kosek mko...@redhat.com
Date: Wed, 14 Jan 2015 13:05:09 +0100
Subject: [PATCH] Fix IPA_BACKUP_DIR path name

Path name was not updated during patch rebase.

https://fedorahosted.org/freeipa/ticket/4797
---
 ipaserver/install/ipa_restore.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index 9d308eff657e7b6223b9597d741af091268801ad..d93ddc79ecacdf660359d0db7831285ba7e0e3cb 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -172,7 +172,7 @@ def validate_options(self):
 
 dirname = self.args[0]
 if not os.path.isabs(dirname):
-dirname = os.path.join(BACKUP_DIR, dirname)
+dirname = os.path.join(paths.IPA_BACKUP_DIR, dirname)
 if not os.path.isdir(dirname):
 parser.error(must provide path to backup directory)
 
@@ -207,7 +207,7 @@ def run(self):
 
 self.backup_dir = self.args[0]
 if not os.path.isabs(self.backup_dir):
-self.backup_dir = os.path.join(BACKUP_DIR, self.backup_dir)
+self.backup_dir = os.path.join(paths.IPA_BACKUP_DIR, self.backup_dir)
 
 self.log.info(Preparing restore from %s on %s,
   self.backup_dir, api.env.host)
-- 
1.9.3

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-13 Thread Jan Cholasta

Dne 13.1.2015 v 17:45 Jan Cholasta napsal(a):

Dne 13.1.2015 v 16:37 Petr Vobornik napsal(a):

On 01/13/2015 02:26 PM, Jan Cholasta wrote:

Dne 13.1.2015 v 13:01 Petr Vobornik napsal(a):

On 01/12/2015 02:28 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes
https://fedorahosted.org/freeipa/ticket/4797.

Note that --data with data-only backup and --logs-only with data-only
restore are deliberately ignored and considered no-op.

Honza





3. When #2 fixed, data backup with --no-logs doesn't raise warning as
requested in ticket.


IMO such a warning does not make sense. You request no logs, you get no
logs, I don't see anything worth warning about here.


ok, makes sense





5. Nitpick: imho option validation should be done before temp dir
creation.


Fixed.


You've also moved
   self.header = os.path.join(self.backup_dir, 'header')
below
   self.read_header()

-- restore fails everytime


Silly me. Sorry. Fixed.

Rebased updated patch attached.


Rebased again, patch attached.

--
Jan Cholasta
From 3f4e54a89b8d7a1cec5576e32e74d6f71664e0b5 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Mon, 12 Jan 2015 12:44:21 +
Subject: [PATCH] Fix validation of ipa-restore options

Fix restore mode checks. Do some of the existing checks earlier to make them
effective. Check if --instance and --backend exist both in the filesystem and
in the backup.

Log backup type and restore mode before performing restore.

Update ipa-restore man page.

https://fedorahosted.org/freeipa/ticket/4797
---
 install/tools/man/ipa-restore.1  |   8 +-
 ipaserver/install/ipa_restore.py | 175 +++
 2 files changed, 107 insertions(+), 76 deletions(-)

diff --git a/install/tools/man/ipa-restore.1 b/install/tools/man/ipa-restore.1
index d758490..5f40181 100644
--- a/install/tools/man/ipa-restore.1
+++ b/install/tools/man/ipa-restore.1
@@ -65,16 +65,16 @@ Restore the data only. The default is to restore everything in the backup.
 The full path to a GPG keyring. The keyring consists of two files, a public and a private key (.sec and .pub respectively). Specify the path without an extension.
 .TP
 \fB\-\-no\-logs\fR
-Exclude the IPA service log files in the backup (if they were backed up). Applicable only with a full backup.
+Exclude the IPA service log files in the backup (if they were backed up).
 .TP
 \fB\-\-online\fR
-Perform the restore on\-line. Requires the \-\-data option.
+Perform the restore on\-line. Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-instance\fR=\fIINSTANCE\fR
-Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance).
+Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance). Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-backend\fR=\fIBACKEND\fR
-The backend to restore within an instance or instances.
+The backend to restore within an instance or instances. Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-v\fR, \fB\-\-verbose\fR
 Print debugging information
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index cd98d07..be48716 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -25,6 +25,7 @@ import time
 import pwd
 from ConfigParser import SafeConfigParser
 import ldif
+import itertools
 
 from ipalib import api, errors
 from ipapython import version, ipautil, certdb, dogtag
@@ -161,32 +162,25 @@ class Restore(admintool.AdminTool):
 
 
 def validate_options(self):
+parser = self.option_parser
 options = self.options
 super(Restore, self).validate_options(needs_root=True)
-if options.data_only:
-installutils.check_server_configuration()
 
 if len(self.args)  1:
-self.option_parser.error(
-must provide the backup to restore)
+parser.error(must provide the backup to restore)
 elif len(self.args)  1:
-self.option_parser.error(
-must provide exactly one name for the backup)
+parser.error(must provide exactly one name for the backup)
 
 dirname = self.args[0]
 if not os.path.isabs(dirname):
-self.backup_dir = os.path.join(BACKUP_DIR, dirname)
-else:
-self.backup_dir = dirname
-
+dirname = os.path.join(BACKUP_DIR, dirname)
 if not os.path.isdir(dirname):
-raise self.option_parser.error(must provide path to backup directory)
+parser.error(must provide path to backup directory)
 
 if options.gpg_keyring:
 if (not os.path.exists(options.gpg_keyring + '.pub') or
-   not os.path.exists(options.gpg_keyring + '.sec')):
-raise admintool.ScriptError('No such key %s' %
-   

Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-13 Thread Petr Vobornik

On 01/12/2015 02:28 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4797.

Note that --data with data-only backup and --logs-only with data-only
restore are deliberately ignored and considered no-op.

Honza



1. I'm not sure how relative path to backup dir should work:

I have a backup: /var/lib/ipa/backup/ipa-data-2015-01-13-10-53-06/

Absolute path works great. But:
-  ipa-data-2015-01-13-10-53-06
fails with `ipa-restore: error: must provide path to backup directory`

Ugly hybrid (I was in home dir):
../../var/lib/ipa/backup/ipa-data-2015-01-13-10-53-06/
fails with:

/var/lib/ipa/backup/../../var/lib/ipa/backup/ipa-data-2015-01-13-10-53-06/header

I.e., dir name won't pass
 if not os.path.isdir(self.args[0]):
and the second concatenation is weird.

2. Data backup cannot be done because the first 'for' never breaks

+for instance in instances:
+for backend in backends:
+db_dir = (paths.SLAPD_INSTANCE_DB_DIR_TEMPLATE %
+  (instance, backend))
+if os.path.exists(db_dir):
+break
+else:
+raise admintool.ScriptError(
+Cannot restore a data backup into an empty 
system)


3. When #2 fixed, data backup with --no-logs doesn't raise warning as 
requested in ticket.


4. Since backup type is detected automatically(--data doesn't have to be 
specified for data restore), I guess that the ticket requirement: `Here 
expecting an error message that --online option can only provided along 
with --data option. ` is invalid, right?


Man page states that --online requires --data option, which is not true.

5. Nitpick: imho option validation should be done before temp dir creation.

6. pep8, fixing them is up to you:

./ipaserver/install/ipa_restore.py:150:5: E129 visually indented line 
with same indent as next logical line
./ipaserver/install/ipa_restore.py:184:13: E128 continuation line 
under-indented for visual indent

--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-13 Thread Jan Cholasta

Dne 13.1.2015 v 13:01 Petr Vobornik napsal(a):

On 01/12/2015 02:28 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4797.

Note that --data with data-only backup and --logs-only with data-only
restore are deliberately ignored and considered no-op.

Honza



1. I'm not sure how relative path to backup dir should work:

I have a backup: /var/lib/ipa/backup/ipa-data-2015-01-13-10-53-06/

Absolute path works great. But:
-  ipa-data-2015-01-13-10-53-06
fails with `ipa-restore: error: must provide path to backup directory`

Ugly hybrid (I was in home dir):
 ../../var/lib/ipa/backup/ipa-data-2015-01-13-10-53-06/
fails with:

/var/lib/ipa/backup/../../var/lib/ipa/backup/ipa-data-2015-01-13-10-53-06/header


I.e., dir name won't pass
  if not os.path.isdir(self.args[0]):
and the second concatenation is weird.


man ipa-restore says:

Only the name of the backup needs to be passed in, not the full 
path. Backups are stored in a subdirectory in /var/lib/ipa/backup. If a 
backup is in another location then the full path must be provided.


This was validated wrong, fixed.



2. Data backup cannot be done because the first 'for' never breaks

+for instance in instances:
+for backend in backends:
+db_dir = (paths.SLAPD_INSTANCE_DB_DIR_TEMPLATE %
+  (instance, backend))
+if os.path.exists(db_dir):
+break
+else:
+raise admintool.ScriptError(
+Cannot restore a data backup into an empty
system)


Oops, fixed.



3. When #2 fixed, data backup with --no-logs doesn't raise warning as
requested in ticket.


IMO such a warning does not make sense. You request no logs, you get no 
logs, I don't see anything worth warning about here.




4. Since backup type is detected automatically(--data doesn't have to be
specified for data restore), I guess that the ticket requirement: `Here
expecting an error message that --online option can only provided along
with --data option. ` is invalid, right?

Man page states that --online requires --data option, which is not true.


Fixed in man page.



5. Nitpick: imho option validation should be done before temp dir creation.


Fixed.



6. pep8, fixing them is up to you:

./ipaserver/install/ipa_restore.py:150:5: E129 visually indented line
with same indent as next logical line
./ipaserver/install/ipa_restore.py:184:13: E128 continuation line
under-indented for visual indent


Fixed.

Updated patch attached.

--
Jan Cholasta
From 44801a195e293b790fc7ec08bff04e8d0cf29787 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Mon, 12 Jan 2015 12:44:21 +
Subject: [PATCH] Fix validation of ipa-restore options

Fix restore mode checks. Do some of the existing checks earlier to make them
effective. Check if --instance and --backend exist both in the filesystem and
in the backup.

Log backup type and restore mode before performing restore.

Update ipa-restore man page.

https://fedorahosted.org/freeipa/ticket/4797
---
 install/tools/man/ipa-restore.1  |   8 +-
 ipaserver/install/ipa_restore.py | 176 +++
 2 files changed, 108 insertions(+), 76 deletions(-)

diff --git a/install/tools/man/ipa-restore.1 b/install/tools/man/ipa-restore.1
index d758490..5f40181 100644
--- a/install/tools/man/ipa-restore.1
+++ b/install/tools/man/ipa-restore.1
@@ -65,16 +65,16 @@ Restore the data only. The default is to restore everything in the backup.
 The full path to a GPG keyring. The keyring consists of two files, a public and a private key (.sec and .pub respectively). Specify the path without an extension.
 .TP
 \fB\-\-no\-logs\fR
-Exclude the IPA service log files in the backup (if they were backed up). Applicable only with a full backup.
+Exclude the IPA service log files in the backup (if they were backed up).
 .TP
 \fB\-\-online\fR
-Perform the restore on\-line. Requires the \-\-data option.
+Perform the restore on\-line. Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-instance\fR=\fIINSTANCE\fR
-Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance).
+Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance). Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-backend\fR=\fIBACKEND\fR
-The backend to restore within an instance or instances.
+The backend to restore within an instance or instances. Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-v\fR, \fB\-\-verbose\fR
 Print debugging information
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index 0977039..dbebd83 100644
--- a/ipaserver/install/ipa_restore.py
+++ 

Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-13 Thread Petr Vobornik

On 01/13/2015 02:26 PM, Jan Cholasta wrote:

Dne 13.1.2015 v 13:01 Petr Vobornik napsal(a):

On 01/12/2015 02:28 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4797.

Note that --data with data-only backup and --logs-only with data-only
restore are deliberately ignored and considered no-op.

Honza





3. When #2 fixed, data backup with --no-logs doesn't raise warning as
requested in ticket.


IMO such a warning does not make sense. You request no logs, you get no
logs, I don't see anything worth warning about here.


ok, makes sense





5. Nitpick: imho option validation should be done before temp dir
creation.


Fixed.


You've also moved
  self.header = os.path.join(self.backup_dir, 'header')
below
  self.read_header()

-- restore fails everytime



Updated patch attached.



--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-13 Thread Jan Cholasta

Dne 13.1.2015 v 16:37 Petr Vobornik napsal(a):

On 01/13/2015 02:26 PM, Jan Cholasta wrote:

Dne 13.1.2015 v 13:01 Petr Vobornik napsal(a):

On 01/12/2015 02:28 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes
https://fedorahosted.org/freeipa/ticket/4797.

Note that --data with data-only backup and --logs-only with data-only
restore are deliberately ignored and considered no-op.

Honza





3. When #2 fixed, data backup with --no-logs doesn't raise warning as
requested in ticket.


IMO such a warning does not make sense. You request no logs, you get no
logs, I don't see anything worth warning about here.


ok, makes sense





5. Nitpick: imho option validation should be done before temp dir
creation.


Fixed.


You've also moved
   self.header = os.path.join(self.backup_dir, 'header')
below
   self.read_header()

-- restore fails everytime


Silly me. Sorry. Fixed.

Rebased updated patch attached.

--
Jan Cholasta
From 23bb1f4c1ea36f586b7ae43d01585fee7e677135 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Mon, 12 Jan 2015 12:44:21 +
Subject: [PATCH] Fix validation of ipa-restore options

Fix restore mode checks. Do some of the existing checks earlier to make them
effective. Check if --instance and --backend exist both in the filesystem and
in the backup.

Log backup type and restore mode before performing restore.

Update ipa-restore man page.

https://fedorahosted.org/freeipa/ticket/4797
---
 install/tools/man/ipa-restore.1  |   8 +-
 ipaserver/install/ipa_restore.py | 175 +++
 2 files changed, 107 insertions(+), 76 deletions(-)

diff --git a/install/tools/man/ipa-restore.1 b/install/tools/man/ipa-restore.1
index d758490..5f40181 100644
--- a/install/tools/man/ipa-restore.1
+++ b/install/tools/man/ipa-restore.1
@@ -65,16 +65,16 @@ Restore the data only. The default is to restore everything in the backup.
 The full path to a GPG keyring. The keyring consists of two files, a public and a private key (.sec and .pub respectively). Specify the path without an extension.
 .TP
 \fB\-\-no\-logs\fR
-Exclude the IPA service log files in the backup (if they were backed up). Applicable only with a full backup.
+Exclude the IPA service log files in the backup (if they were backed up).
 .TP
 \fB\-\-online\fR
-Perform the restore on\-line. Requires the \-\-data option.
+Perform the restore on\-line. Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-instance\fR=\fIINSTANCE\fR
-Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance).
+Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance). Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-backend\fR=\fIBACKEND\fR
-The backend to restore within an instance or instances.
+The backend to restore within an instance or instances. Requires data\-only backup or the \-\-data option.
 .TP
 \fB\-\-v\fR, \fB\-\-verbose\fR
 Print debugging information
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index f3a60fc..07bf52e 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -24,6 +24,7 @@ import tempfile
 import time
 import pwd
 from ConfigParser import SafeConfigParser
+import itertools
 
 from ipalib import api, errors
 from ipapython import version, ipautil, certdb, dogtag
@@ -134,32 +135,25 @@ class Restore(admintool.AdminTool):
 
 
 def validate_options(self):
+parser = self.option_parser
 options = self.options
 super(Restore, self).validate_options(needs_root=True)
-if options.data_only:
-installutils.check_server_configuration()
 
 if len(self.args)  1:
-self.option_parser.error(
-must provide the backup to restore)
+parser.error(must provide the backup to restore)
 elif len(self.args)  1:
-self.option_parser.error(
-must provide exactly one name for the backup)
+parser.error(must provide exactly one name for the backup)
 
 dirname = self.args[0]
 if not os.path.isabs(dirname):
-self.backup_dir = os.path.join(BACKUP_DIR, dirname)
-else:
-self.backup_dir = dirname
-
+dirname = os.path.join(BACKUP_DIR, dirname)
 if not os.path.isdir(dirname):
-raise self.option_parser.error(must provide path to backup directory)
+parser.error(must provide path to backup directory)
 
 if options.gpg_keyring:
 if (not os.path.exists(options.gpg_keyring + '.pub') or
-   not os.path.exists(options.gpg_keyring + '.sec')):
-raise admintool.ScriptError('No such key %s' %
-options.gpg_keyring)
+not 

[Freeipa-devel] [PATCH] 387 Fix validation of ipa-restore options

2015-01-12 Thread Jan Cholasta

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4797.

Note that --data with data-only backup and --logs-only with data-only 
restore are deliberately ignored and considered no-op.


Honza

--
Jan Cholasta
From 6b14a609d726f5b6dc8e94b1d3d21123637599c1 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Mon, 12 Jan 2015 12:44:21 +
Subject: [PATCH] Fix validation of ipa-restore options

Fix restore mode checks. Do some of the existing checks earlier to make them
effective. Check if --instance and --backend exist both in the filesystem and
in the backup.

Log backup type and restore mode before performing restore.

Update ipa-restore man page.

https://fedorahosted.org/freeipa/ticket/4797
---
 install/tools/man/ipa-restore.1  |   6 +-
 ipaserver/install/ipa_restore.py | 159 +++
 2 files changed, 97 insertions(+), 68 deletions(-)

diff --git a/install/tools/man/ipa-restore.1 b/install/tools/man/ipa-restore.1
index d758490..e94d92f 100644
--- a/install/tools/man/ipa-restore.1
+++ b/install/tools/man/ipa-restore.1
@@ -65,16 +65,16 @@ Restore the data only. The default is to restore everything in the backup.
 The full path to a GPG keyring. The keyring consists of two files, a public and a private key (.sec and .pub respectively). Specify the path without an extension.
 .TP
 \fB\-\-no\-logs\fR
-Exclude the IPA service log files in the backup (if they were backed up). Applicable only with a full backup.
+Exclude the IPA service log files in the backup (if they were backed up).
 .TP
 \fB\-\-online\fR
 Perform the restore on\-line. Requires the \-\-data option.
 .TP
 \fB\-\-instance\fR=\fIINSTANCE\fR
-Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance).
+Restore only the databases in this 389\-ds instance. The default is to restore all found (at most this is the IPA REALM instance and the PKI\-IPA instance). Requires the \-\-data option.
 .TP
 \fB\-\-backend\fR=\fIBACKEND\fR
-The backend to restore within an instance or instances.
+The backend to restore within an instance or instances. Requires the \-\-data option.
 .TP
 \fB\-\-v\fR, \fB\-\-verbose\fR
 Print debugging information
diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index 0977039..ce7aa62 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -134,32 +134,21 @@ class Restore(admintool.AdminTool):
 
 
 def validate_options(self):
+parser = self.option_parser
 options = self.options
 super(Restore, self).validate_options(needs_root=True)
-if options.data_only:
-installutils.check_server_configuration()
 
 if len(self.args)  1:
-self.option_parser.error(
-must provide the backup to restore)
+parser.error(must provide the backup to restore)
 elif len(self.args)  1:
-self.option_parser.error(
-must provide exactly one name for the backup)
-
-dirname = self.args[0]
-if not os.path.isabs(dirname):
-self.backup_dir = os.path.join(BACKUP_DIR, dirname)
-else:
-self.backup_dir = dirname
-
-if not os.path.isdir(dirname):
-raise self.option_parser.error(must provide path to backup directory)
+parser.error(must provide exactly one name for the backup)
+if not os.path.isdir(self.args[0]):
+parser.error(must provide path to backup directory)
 
 if options.gpg_keyring:
 if (not os.path.exists(options.gpg_keyring + '.pub') or
-   not os.path.exists(options.gpg_keyring + '.sec')):
-raise admintool.ScriptError('No such key %s' %
-options.gpg_keyring)
+not os.path.exists(options.gpg_keyring + '.sec')):
+parser.error(no such key %s % options.gpg_keyring)
 
 
 def ask_for_options(self):
@@ -185,38 +174,14 @@ class Restore(admintool.AdminTool):
 api.bootstrap(in_server=False, context='restore')
 api.finalize()
 
-self.log.info(Preparing restore from %s on %s,
-self.backup_dir, api.env.host)
-
-if options.instance and options.backend:
-database = (options.instance, options.backend)
-if not os.path.exists(paths.SLAPD_INSTANCE_DB_DIR_TEMPLATE %
-  database):
-raise admintool.ScriptError(
-Instance %s with backend %s does not exist % database)
-
-databases = [database]
+dirname = self.args[0]
+if not os.path.isabs(dirname):
+self.backup_dir = os.path.join(BACKUP_DIR, dirname)
 else:
-if options.instance:
-instances = [options.instance]
-else:
-instances =