title: How to backup MySQL database from NSIS
body: <p>I need to backup a MySQL database from an NSIS installer. I am missing something trivial in the scripts I tried:</p>
  
  <pre><code>nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName --execute="source D:\$dbName.sql"' $0
  
  nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName --execute="D:\$dbName.sql"' $0
  
  nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --execute="--user=$username --password=$password --routines $dbName D:\$dbName.sql"' $0
  
  nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName "D:\$dbName.sql"' $0
  
  nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password /c echo --routines $dbName &gt; "D:\$dbName.sql"' $0
  
  ExecWait '"$1" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName &gt; "D:\$dbName.sql"' $0
  
  ExecWait '/C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName &gt; "D:\$dbName.sql"' $0
  
  StrCpy $BACKUPFILE "D:\ctvi.sql"
  StrCpy $1 $BACKUPFILE
  ExpandEnvStrings $2 %COMSPEC%
  ExecWait '"$2" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password $dbName &gt; $1' $0
  
  ExecWait '/C "$mySqlDirectory\bin\mysqldump.exe" -u$username --password=$password -R $dbName &gt;"D:\$dbName.sql"' $0
  </code></pre>
  
  <p>None of them worked. Passing argument is not my strongest suit :(</p>