Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python, Lua, Tcl, C and C++ training - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, Ruby, MySQL and Linux / Tomcat systems
 
Commenting out an echo killed my bash backup script

"Commenting out an echo killed my bash script" - yes, really!

Here (with password amended!) is part of my bash script which takes a database snapshot from time to time - and it's been running well over a 24 hour cycle, giving me checkpoints to return to. But it was getting a bit verbose, so I added a simple # in front of the successful emailing ine.

  /usr/local/mysql/bin/mysqldump -ufgw -psummathere -h127.0.0.1 fgw > /home/backups/$HOUR/fgw.sql
  if [ "$?" -eq 0 ]; then
    echo "Success $HOUR fgw" | mail -s "FGW good dump" graham@wellho.net
  else
    echo "Mysqldump encountered a problem $HOUR fgw" | mail -s "FGW BAD dump" graham@wellho.net
  fi


My change got rid of the good backup message which had been "spamming" me during testing ... but it also got rid of the rest of my backup procedure. Oops. It turns out that you're not allowed an empty block in an if!

Advise is to refactor the script - or to add a null statement into the block if you want to retain the ability to uncomment the echo and start emailing again (or whatever your programmer-switchable action is!). Suitable null statements are
  :
(yes, a sinle colon) or
  echo nothing > /dev/null
but please note I have not yet tested these. I'm more concerned, as I write this, to be handcranking a backup and watching the backup pots refill with complete data sets!
(written 2015-01-19)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
A162 - Web Application Deployment - Backups and File System Management
  [4481] Extracting data from backups to restore selected rows from MySQL tables - (2015-05-01)
  [4405] Backup procedures - via backup server - (2015-01-24)
  [4390] Checking MySQL database backups have worked (not failed) - (2015-01-10)
  [4115] More or less back - what happened to our server the other day - (2013-06-14)
  [4063] Backups by crossover between network centres - setting up automatic scp transfers - (2013-04-13)
  [4056] An overpractical test of our backup strategy! - (2013-03-30)
  [2299] How much space does my directory take - Linux - (2009-07-20)
  [1893] Some Linux and Unix tips - (2008-11-18)
  [1801] Will your backups work if you have to restore them? - (2008-09-18)
  [1765] Dialects of English and Unix - (2008-08-21)
  [1648] The tourists guide to Linux - (2008-05-20)
  [1439] Linux / Unix - layout of operating system files - (2007-11-20)
  [1288] Linux run states, shell special commands, and directory structures - (2007-08-03)
  [1023] Finding public writeable things on your linux file system - (2007-01-06)
  [1013] Copy multiple files - confusing error message from cp - (2006-12-30)
  [754] tar, jar, war, ear, sar files - (2006-06-10)
  [735] Boys will be boys, saved by Ubuntu - (2006-05-27)
  [703] Copying files and preserving ownership - (2006-04-28)
  [593] Finding where the disc space has gone - (2006-02-06)
  [554] What backup is adequate? - (2006-01-04)
  [334] Symbolic links and hard links - (2005-06-02)
  [153] Linux - where to put swap space - (2004-12-16)

A167 - Web Application Deployment - Shell Programming (bash)
  [4587] shell - bash. Writing conditional tests and statements - the options available - (2015-11-28)
  [4586] Extending your bash shell with aliases, functions and extra commands - (2015-11-28)
  [4584] Bash ... some new scripts to - handling user input - (2015-11-27)
  [4487] Starting MySQL. ERROR! The server quit without updating PID file - how we fixed it. - (2015-05-06)
  [3791] The Kernel, Shells and Daemons. Greek Gods in computing - (2012-07-01)
  [1904] Ruby, Perl, Linux, MySQL - some training notes - (2008-11-23)
  [1527] Selecting file names in a shell - one word or another - (2008-02-02)
  [1468] Lexical v Arithemetic testing, Bash and Perl - (2007-12-11)
  [1345] Perl and Shell coding standards / costs of an IT project - (2007-09-11)
  [1287] Work and play at Well House Manor - Football and Shell Shortcuts - (2007-08-02)
  [827] No news is good news with Unix and Linux - (2006-08-10)
  [749] Cottage industry or production line data handling methods - (2006-06-07)
  [64] Shell Script for CGI on the web - (2004-09-26)
  [63] Almost like old times - (2004-09-26)


Back to
The Campus in Melksham - name, logo, and livery choice
Previous and next
or
Horse's mouth home
Forward to
Selecting RECENT and POPULAR news and trends for your web site users
Some other Articles
Which (virtual) host was visited? Tuning Apache log files, and Python analysis
The unbalanced relationship between customer and provider
Finding sum, minimum, maximum and average in Python (and Ruby)
Selecting RECENT and POPULAR news and trends for your web site users
Commenting out an echo killed my bash backup script
The Campus in Melksham - name, logo, and livery choice
Accessing variables across subroutine boundaries - Perl, Python, Java and Tcl
TransWilts / Press and Publicity report for AGM / 30th January 2015
Java Utility class - flexible replacement for array. Also cacheing in objects and multiple catch clauses example.
Preparing data through a little bit of Perl
4755 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4400_Com ... cript.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat