Created
May 7, 2012 17:05
-
-
Save coltrane/2629002 to your computer and use it in GitHub Desktop.
example data dump with retry on failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
result= | |
while (( $result )) || [ -z "$result" ]; do | |
node dump_data_for_backup.js > backup.json | |
result=$? | |
# there is no way to distinguish node's (1) exit code on SIGINT (and SIGTERM) | |
# from a (1) exit code due to normal exit call in userland. | |
# if node preserved SIGINT/SIGTERM, then the shell would detect node's | |
# "abnormal exit" status, and the script would terminate right here. | |
# as it stands, it will be very difficult to terminate this script | |
# using Ctrl-C (SIGINT) or SIGTERM. | |
if (( $result != 0 )) ; then | |
echo -e "\nbackup failed ($result). retrying..." | |
fi | |
done | |
echo ">> backup-$(date +%Y%m%d).json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment