How to backup MySQL database from NSIS

放肆的年华 提交于 2019-12-25 01:48:55

问题


I need to backup a MySQL database from an NSIS installer. I am missing something trivial in the scripts I tried:

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 > "D:\$dbName.sql"' $0

ExecWait '"$1" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName > "D:\$dbName.sql"' $0

ExecWait '/C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName > "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 > $1' $0

ExecWait '/C "$mySqlDirectory\bin\mysqldump.exe" -u$username --password=$password -R $dbName >"D:\$dbName.sql"' $0

None of them worked. Passing argument is not my strongest suit :(


回答1:


This worked for me:

StrCpy $1 "D:\ctvi.sql"
ExpandEnvStrings $2 %COMSPEC%
ExecDos::exec /NOUNLOAD '"$2" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password $dbName > $1' $0

Its important not to include the path "D:\ctvi.sql" as such in the execute command, also not to quote the path variable. That is why I have used $1, that too without quoting.



来源:https://stackoverflow.com/questions/11638294/how-to-backup-mysql-database-from-nsis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!