<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Exit code issue when using a shell script to quiesce a MySQL database in Data Protection</title>
    <link>https://community.netapp.com/t5/Data-Protection/Exit-code-issue-when-using-a-shell-script-to-quiesce-a-MySQL-database/m-p/57818#M1530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to setup up SnapCreator for MySQL for a customer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At first, we tried the integrated plug-in, but it seems that we're facing a net::mysql issue, as the script doesn't work more than once when the agent is fresh started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I found a script to quiesce all databases with mysql commands.&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13839251439928482" jivemacro_uid="_13839251439928482" modifiedtitle="true"&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;#set -x&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#set $(date)&lt;/P&gt;&lt;P&gt;#str_Tag=$(date +%A);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;MYSQL_PWD="toto"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;DBASELIST=`mktemp`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;mysqlshow -p$MYSQL_PWD | awk '{print $2}' | grep -v Databases | sort &amp;gt;$DBASELIST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;# Flush of databases&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;for x in `cat $DBASELIST`; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mysql -u root -p$MYSQL_PWD $x -e "flush tables with read lock" -v&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mysql -u root -p$MYSQL_PWD $x -e "flush logs" -v&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;done;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;My issue is that when the backup runs, the result of the script that is sent to the server is -1, which the server interprets as a no-go for the snapshot.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## APPLICATION QUIESCE COMMANDS ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,091] INFO: [dbmasterbkp:9090 (4.0.0.1)] Executing Application quiesce command [/home/pentaadmin/netapp/quiesce.sh] on dbmasterbkp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,091] DEBUG: [dbmasterbkp:9090 (4.0.0.1)] Executing command [/home/pentaadmin/netapp/quiesce.sh]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,091] TRACE: Command [/home/pentaadmin/netapp/quiesce.sh] finished with&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;exit code: [-1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stdout: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stderr: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,092] ERROR: [dbmasterbkp:9090 (4.0.0.1)] Command [/home/pentaadmin/netapp/quiesce.sh] failed with return code [-1] and message []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## Application not defined. Skipping Unquiesce task ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## Snap Creator Framework 4.0p1 failed ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## PRE EXIT COMMANDS ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] INFO: [dbmasterbkp:9090 (4.0.0.1)] Executing Pre Exit command [/home/pentaadmin/netapp/unquiesce.sh] on dbmasterbkp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] DEBUG: [dbmasterbkp:9090 (4.0.0.1)] Executing command [/home/pentaadmin/netapp/unquiesce.sh]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] TRACE: Command [/home/pentaadmin/netapp/unquiesce.sh] finished with&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;exit code: [-1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stdout: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stderr: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] ERROR: [dbmasterbkp:9090 (4.0.0.1)] Command [/home/pentaadmin/netapp/unquiesce.sh] failed with return code [-1] and message []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script runs well, and if I run it manually, and then I enter &lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;gt;echo $?&lt;/SPAN&gt;, the exit code comes at &lt;SPAN style="font-family: 'courier new', courier;"&gt;0&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to add something at the end of the script ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jun 2025 05:49:55 GMT</pubDate>
    <dc:creator>jcbettinelli</dc:creator>
    <dc:date>2025-06-05T05:49:55Z</dc:date>
    <item>
      <title>Exit code issue when using a shell script to quiesce a MySQL database</title>
      <link>https://community.netapp.com/t5/Data-Protection/Exit-code-issue-when-using-a-shell-script-to-quiesce-a-MySQL-database/m-p/57818#M1530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to setup up SnapCreator for MySQL for a customer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At first, we tried the integrated plug-in, but it seems that we're facing a net::mysql issue, as the script doesn't work more than once when the agent is fresh started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I found a script to quiesce all databases with mysql commands.&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13839251439928482" jivemacro_uid="_13839251439928482" modifiedtitle="true"&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;#set -x&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#set $(date)&lt;/P&gt;&lt;P&gt;#str_Tag=$(date +%A);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;MYSQL_PWD="toto"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;DBASELIST=`mktemp`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;mysqlshow -p$MYSQL_PWD | awk '{print $2}' | grep -v Databases | sort &amp;gt;$DBASELIST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;# Flush of databases&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;for x in `cat $DBASELIST`; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mysql -u root -p$MYSQL_PWD $x -e "flush tables with read lock" -v&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mysql -u root -p$MYSQL_PWD $x -e "flush logs" -v&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;done;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;My issue is that when the backup runs, the result of the script that is sent to the server is -1, which the server interprets as a no-go for the snapshot.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## APPLICATION QUIESCE COMMANDS ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,091] INFO: [dbmasterbkp:9090 (4.0.0.1)] Executing Application quiesce command [/home/pentaadmin/netapp/quiesce.sh] on dbmasterbkp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,091] DEBUG: [dbmasterbkp:9090 (4.0.0.1)] Executing command [/home/pentaadmin/netapp/quiesce.sh]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,091] TRACE: Command [/home/pentaadmin/netapp/quiesce.sh] finished with&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;exit code: [-1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stdout: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stderr: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,092] ERROR: [dbmasterbkp:9090 (4.0.0.1)] Command [/home/pentaadmin/netapp/quiesce.sh] failed with return code [-1] and message []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## Application not defined. Skipping Unquiesce task ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## Snap Creator Framework 4.0p1 failed ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;########## PRE EXIT COMMANDS ##########&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] INFO: [dbmasterbkp:9090 (4.0.0.1)] Executing Pre Exit command [/home/pentaadmin/netapp/unquiesce.sh] on dbmasterbkp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] DEBUG: [dbmasterbkp:9090 (4.0.0.1)] Executing command [/home/pentaadmin/netapp/unquiesce.sh]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] TRACE: Command [/home/pentaadmin/netapp/unquiesce.sh] finished with&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;exit code: [-1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stdout: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;stderr: []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[2013-11-08 16:11:26,360] ERROR: [dbmasterbkp:9090 (4.0.0.1)] Command [/home/pentaadmin/netapp/unquiesce.sh] failed with return code [-1] and message []&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script runs well, and if I run it manually, and then I enter &lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;gt;echo $?&lt;/SPAN&gt;, the exit code comes at &lt;SPAN style="font-family: 'courier new', courier;"&gt;0&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to add something at the end of the script ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 05:49:55 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Data-Protection/Exit-code-issue-when-using-a-shell-script-to-quiesce-a-MySQL-database/m-p/57818#M1530</guid>
      <dc:creator>jcbettinelli</dc:creator>
      <dc:date>2025-06-05T05:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Exit code issue when using a shell script to quiesce a MySQL database</title>
      <link>https://community.netapp.com/t5/Data-Protection/Exit-code-issue-when-using-a-shell-script-to-quiesce-a-MySQL-database/m-p/57824#M1531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may want to supply your own exit code within the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a good amount of discussion here.&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://stackoverflow.com/questions/64786/error-handling-in-bash" title="http://stackoverflow.com/questions/64786/error-handling-in-bash" target="_blank"&gt;http://stackoverflow.com/questions/64786/error-handling-in-bash&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will also test your code in the lab and update here with my findings.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2013 14:55:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Data-Protection/Exit-code-issue-when-using-a-shell-script-to-quiesce-a-MySQL-database/m-p/57824#M1531</guid>
      <dc:creator>sivar</dc:creator>
      <dc:date>2013-11-12T14:55:43Z</dc:date>
    </item>
  </channel>
</rss>

