Alvast wat code voor backup/restore bij elkaar gezocht

This commit is contained in:
Eelke Klein 2017-01-17 19:04:47 +01:00
parent 2b012b70eb
commit ea30dd9c0e
4 changed files with 72 additions and 1 deletions

66
backuprestore.cpp Normal file
View 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);
}

View file

@ -33,3 +33,4 @@ int main(int argc, char *argv[])
return result; return result;
} }

View file

@ -33,7 +33,8 @@ SOURCES += main.cpp\
databasewindow.cpp \ databasewindow.cpp \
connectionmanagerwindow.cpp \ connectionmanagerwindow.cpp \
connectionlistmodel.cpp \ connectionlistmodel.cpp \
connectionconfig.cpp connectionconfig.cpp \
backuprestore.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
serverproperties.h \ serverproperties.h \

View file

@ -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"-(|\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"-(|\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)-"; R"-(|\bwhere\b|\bwith\b|(?:(?:inner|(?:left|right|full)(\s+outer)?)\s+)?join)-";
// into temp DISTINCT true false
static auto types = 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"-(\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)-"; R"-(|\btime\b|\btimestamp(?:tz)?\b|\btimestamp(?:\s+with\s+time\s+zone)?\b|\bvarchar\b)-";