Alvast wat code voor backup/restore bij elkaar gezocht
This commit is contained in:
parent
2b012b70eb
commit
ea30dd9c0e
4 changed files with 72 additions and 1 deletions
66
backuprestore.cpp
Normal file
66
backuprestore.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#include <QProcess>
|
||||
#include <QProcessEnvironment>
|
||||
#include "connectionconfig.h"
|
||||
|
||||
void setupEnvironment(const ConnectionConfig &cc)
|
||||
{
|
||||
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("PGHOST", cc.host().c_str());
|
||||
env.insert("PGPORT", QString::number(cc.port()));
|
||||
env.insert("PGDATABASE", cc.dbname().c_str());
|
||||
env.insert("PGUSER", cc.user().c_str());
|
||||
env.insert("PGPASSWORD", cc.password().c_str());
|
||||
|
||||
// QProcess process;
|
||||
// process.setProcessEnvironment(env);
|
||||
// process.start("myapp");
|
||||
|
||||
}
|
||||
|
||||
// QString toolpath;
|
||||
// Executable = toolpath + "\\pg_restore.exe";
|
||||
// ExecutableDump = toolpath + "\\pg_dump.exe";
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void Backup(QString dest_file_name)
|
||||
{
|
||||
|
||||
// QString command_line = "\"" + ExecutableDump + "\" ";
|
||||
// // Add commandline options
|
||||
// command_line += "--verbose ";
|
||||
// command_line += "--format=c "; // user option
|
||||
// command_line += " --file=\"" + dest_file_name + "\"";
|
||||
|
||||
QStringList args;
|
||||
args << "--verbose";
|
||||
args << "--format=c";
|
||||
args << "--file=\"" + dest_file_name + "\"";
|
||||
|
||||
QProcess process;
|
||||
process.setProgram("pg_dump.exe");
|
||||
process.setArguments(args);
|
||||
process.start();
|
||||
|
||||
// process.setProcessEnvironment(env);
|
||||
// process.start("myapp");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void Restore(QString bron_file_name)
|
||||
{
|
||||
QProcess process;
|
||||
process.setProgram("pg_restore.exe");
|
||||
|
||||
// QString command_line = "\"" + ExecutableRestore + "\" ";
|
||||
// command_line += "--verbose --no-password --no-privileges --no-owner --dbname=\"" + DbConfig.DbNaam + "\" \"" + bron_file_name + "\"";
|
||||
|
||||
// ExecProg = new ExecuteProgram;
|
||||
// ExecProg->Startup(command_line, Env.GetRawData(), Handle, WM_USER);
|
||||
}
|
||||
|
||||
|
||||
1
main.cpp
1
main.cpp
|
|
@ -33,3 +33,4 @@ int main(int argc, char *argv[])
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ SOURCES += main.cpp\
|
|||
databasewindow.cpp \
|
||||
connectionmanagerwindow.cpp \
|
||||
connectionlistmodel.cpp \
|
||||
connectionconfig.cpp
|
||||
connectionconfig.cpp \
|
||||
backuprestore.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
serverproperties.h \
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ SqlHighlighter::SqlHighlighter(QTextDocument *parent)
|
|||
R"-(|\foreign\b|\bfrom\b|\bgroup\b|\bhaving\b|\bin\b|\bindex\b|\bis\b|\bkey\b|\blimit\b|\bnatural\b|\bnot\b|\bnull\b|\boffset\b|\bon\b)-"
|
||||
R"-(|\bor\b|\border\b|\bover\b|\bparition\b|\bprimary\b|\breferences\b|\brestrict\b|\bselect\b|\btable\b|\btruncate\b|\bunique\b|\bupdate\b|\busing\b)-"
|
||||
R"-(|\bwhere\b|\bwith\b|(?:(?:inner|(?:left|right|full)(\s+outer)?)\s+)?join)-";
|
||||
|
||||
// into temp DISTINCT true false
|
||||
|
||||
static auto types =
|
||||
R"-(\bbigint\b|\bboolean\b|\bchar\b|\bcharacter varying\b|\bdate\b|\bint[248]\b|\binteger\b|\bnumeric\b|\bsmallint\b)-"
|
||||
R"-(|\btime\b|\btimestamp(?:tz)?\b|\btimestamp(?:\s+with\s+time\s+zone)?\b|\bvarchar\b)-";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue