Re: How to tell when database backup has finished?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I’m really not on form this week, maybe I should just go home l-)

 

Thanks to Mark and Noriko for the thoughts and suggestions, and of course Rich for his patience!

 

Here’s that script again, it’s cut down so still might not be bug free, however STATUS -1 means the backup task failed I’ve taken that into account in this version (I just forgot, J).

 

INSTANCE=<hostname>;                                        # Hostname is the default instance name.

BACKUPCMD="/usr/lib64/dirsrv/slapd-${INSTANCE}/db2bak.pl";  # 389-DS Backup Script.

HOSTURI="<LDAP URL>"                                        # Search this host for backup task

PWFILE="/root/.389ds-pw"

BINDAS="cn=Directory Manager"                               # Connect to Directory as this user.

BACKUPOPTS="-j ${PWFILE}"                                   # Tacked in Password File.

BACKUPPATH="/usr/backup/";                                  # Where to store backups

 

# Create temp file to store command results (subshells / subsitution break

#                                            PIPESTATUS)

tempFile=$(mktemp) || {

        echo "Failed to create temporary file for Task ($?)";

        exit 1;

}

 

# Run backup, log if error, added -v + grep/cut to get task CN from output:

${BACKUPCMD} -v -D "${BINDAS}" ${BACKUPOPTS} -a ${DSBACKUPDIR} 2> /dev/null | grep "^cn:" | cut -f2 -d' ' > $tempFile

# Save exit code of $BACKUPCMD (db2bak.pl)

ERR=${PIPESTATUS[0]}

if [ ${ERR} -ne 0 ]; then

        echo "Backup Failed (${ERR}).";

        exit 1;

fi

# Grab the CN

taskCN=$(<${tempFile})

 

STATUS=1

while [ ${STATUS} -ne 0 ]; do

        ldapsearch -x -H ${HOSTURI} -D "${BINDAS}" -y ${PWFILE} -s base -b "cn=${taskCN},cn=backup,cn=tasks,cn=config" nstaskexitcode | grep -i '^nstaskexitcode:' | cut -f2 -d' ' > $tempFile

        ERR=${PIPESTATUS[0]}

# Check that the object was found. If not, assume task completed and we missed

# capturing the exit status.

        if [ $ERR -eq 32 ]; then

                STATUS=0;

        else

                STATUS=$(<${tempFile})

                if [ "${STATUS}" == "" ]; then

                        # No status for task yet, so make script wait.

                        STATUS=1

                fi

        fi

        if [ ${STATUS} -ne 0 ]; then

                if [ ${STATUS} -eq -1 ]; then

                        # Running task has failed for some reason.

                        echo "Backup failed during processing (${STATUS}).";

                        exit 1;

                fi

                # Otherwise, snooze for a bit…

                sleep 5s

        fi

done

 

Hope this helps someone out.

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

GreeNRB
NRB considers its environmental responsibility and goes for green IT.
May we ask you to consider yours before printing this e-mail?  

NRB, daring to commit
This e-mail and any attachments, which may contain information that is confidential and/or protected by intellectual property rights, are intended for the exclusive use of the above-mentioned addressee(s). Any use (including reproduction, disclosure and whole or partial distribution in any form whatsoever) of their content is prohibited without prior authorization of NRB. If you have received this message by error, please contact the sender promptly by resending this e-mail back to him (her), or by calling the above number. Thank you for subsequently deleting this e-mail and any files attached thereto.

--
389 users mailing list
389-users@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/389-users

[Index of Archives]     [Fedora User Discussion]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora News]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora QA]     [Fedora Triage]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Yosemite Photos]     [Linux Apps]     [Maemo Users]     [Gnome Users]     [KDE Users]     [Fedora Tools]     [Fedora Art]     [Fedora Docs]     [Maemo Users]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Fedora ARM]

  Powered by Linux