Skip to content
Snippets Groups Projects
Commit d9bae1af authored by Xueshan Feng's avatar Xueshan Feng
Browse files

Update with more precise information why restore is happened.

parent a5d91b0b
No related branches found
No related tags found
No related merge requests found
......@@ -46,15 +46,19 @@ function mdb_load() {
echo "Latest mdb file in backup: $bakData"
# Restore data and config if LDAP_FORCE_RESTORE is true or newer backup exists or size is smaller then usual.
echo "Comparing timestamps of $bakData and ${LDAP_MDB_DIR}/data.mdb"
if [[ ${LDAP_FORCE_RESTORE} = "true" ]] || [[ ${bakData} -nt ${LDAP_MDB_DIR}/data.mdb ]] \
|| du -sh ${LDAP_MDB_DIR}/data.mdb | grep -q 'M';
then
if [[ ${LDAP_FORCE_RESTORE} = "true" ]]; then
echo "Force restore from ${bakData}"
else
du -sh ${LDAP_MDB_DIR}/data.mdb
echo -e "\nLoading most recent data and config..."
fi
RESTORE="false"
if [[ ${LDAP_FORCE_RESTORE} = "true" ]]; then
echo "Force restore flag is on."
RESTORE="true"
elif [[ -f ${LDAP_MDB_DIR}/data.mdb ]] && [[ ${bakData} -nt ${LDAP_MDB_DIR}/data.mdb ]]; then
echo "${LDAP_MDB_DIR}/data.mdb is newer."
RESTORE="true"
elif [[ -f ${LDAP_MDB_DIR}/data.mdb ]] && du -sh ${LDAP_MDB_DIR}/data.mdb | grep -q 'M'; then
echo "$(du -sh ${LDAP_MDB_DIR}/data.mdb) size is too small."
RESTORE="true"
fi
if [[ ${RESTORE} = "true" ]]; then
echo -e "\nLoading most recent data and config from ${bakData}..."
find ${LDAP_MDB_DIR} -type f -name '*.mdb' -delete
stat --format "Restoring snapshot '%n' modified on %y" ${bakData}
cp -v ${bakData} ${LDAP_MDB_DIR}/data.mdb
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment