Skip to content

Commit 720cf09

Browse files
committed
ipa: print backup and restore logs on failure
These commands fail from time to time, it may be good to have more information then the output.
1 parent aeed829 commit 720cf09

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

  • sssd_test_framework/hosts

sssd_test_framework/hosts/ipa.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,24 @@ def backup(self) -> Any:
127127
def _backup():
128128
return self.conn.run(
129129
"""
130-
set -ex
130+
set -x
131131
132132
function backup {
133133
if [ -d "$1" ] || [ -f "$1" ]; then
134134
cp --force --archive "$1" "$2"
135135
fi
136136
}
137137
138+
rm --force /var/log/ipabackup.log
138139
ipa-backup --data
140+
ret=$?
141+
if [ $ret -ne 0 ]; then
142+
echo "Printing ipa-backup logs..."
143+
cat /var/log/ipabackup.log
144+
exit $ret
145+
fi
146+
147+
set -e
139148
140149
path=`mktemp -d`
141150
mv `find /var/lib/ipa/backup -maxdepth 1 -type d | tail -n 1` $path/ipa
@@ -175,7 +184,7 @@ def restore(self, backup_data: Any | None) -> None:
175184
def _restore():
176185
return self.conn.run(
177186
f"""
178-
set -ex
187+
set -x
179188
180189
function restore {{
181190
rm --force --recursive "$2"
@@ -184,7 +193,16 @@ def _restore():
184193
fi
185194
}}
186195
196+
rm --force /var/log/iparestore.log
187197
ipa-restore --unattended --password "{self.adminpw}" --data "{backup_path}/ipa"
198+
ret=$?
199+
if [ $ret -ne 0 ]; then
200+
echo "Printing ipa-restore logs..."
201+
cat /var/log/iparestore.log
202+
exit $ret
203+
fi
204+
205+
set -e
188206
189207
rm --force --recursive /etc/sssd /var/lib/sss /var/log/sssd
190208
restore "{backup_path}/krb5.conf" /etc/krb5.conf

0 commit comments

Comments
 (0)