}
+#------------------------------------------------------------------------------
+create_checksums() {
+
+ info "Creating checksum files ..."
+
+ if [[ -d "${BACKUP_DIR}" ]] ; then
+ cd "${BACKUP_DIR}"
+ fi
+
+ local cs_type=
+ local cs_file=
+ local cmd=
+
+ for cs_type in "md5" "sha1" "sha256" ; do
+ cs_file="backup-checksums.${cs_type}"
+ info "Creating '${CYAN}${cs_file}${NORMAL}' ..."
+ cmd="${cs_type}sum *.gz > \"${cs_file}\""
+ if [[ "${SIMULATE}" == "y" ]] ; then
+ info "Executing: ${cmd}"
+ continue
+ fi
+ debug "Executing: ${cmd}"
+ eval ${cmd}
+ done
+
+}
+
+#------------------------------------------------------------------------------
+clean_old_backups() {
+
+ info "Removing old backup sets - separation date: '${CYAN}${REMOVE_DATE}${NORMAL}'."
+
+ local i=0
+ local bdir=
+ local bdir_base=
+
+ for bdir in $( ls -1 -d -r "${BACKUP_HOSTDIR}"/* ) ; do
+
+ bdir_base=$( basename "${bdir}" )
+ if [[ "${bdir_base}" == 'lost+found' ]] ; then
+ continue
+ fi
+
+ if [[ ! -d "${bdir}" ]] ; then
+ debug "Path '${CYAN}${bdir}${NORMAL}' is not a directory."
+ continue
+ fi
+
+ if [[ "${bdir}" == "${BACKUP_DIR}" ]] ; then
+ continue
+ fi
+
+ if [[ "${bdir_base}" =~ ^20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]$ ]] ; then
+ :
+ else
+ continue
+ fi
+
+ debug "Checking '${CYAN}${bdir}${NORMAL}' for removing ..."
+ i=$(( $i + 1 ))
+
+ if [[ ${i} -le ${BACKUP_COPIES} ]] ; then
+ continue
+ fi
+
+ info "Removing '${bdir}' ..."
+ RM --recursive "${bdir}"
+
+
+ done
+
+}
+
#------------------------------------------------------------------------------
main() {
check_preferences
do_dir_backup
do_mysql_backup
+ create_checksums
+ clean_old_backups
info "Finished."
}