1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: frmBackupServer.cpp 7243 2008-04-29 09:06:34Z dpage $
5
// Copyright (C) 2002 - 2008, The pgAdmin Development Team
6
// This software is released under the Artistic Licence
8
// frmBackupServer.cpp - Backup server dialogue
10
//////////////////////////////////////////////////////////////////////////
14
#include <wx/settings.h>
19
#include "frm/frmMain.h"
20
#include "frm/frmBackupServer.h"
21
#include "utils/sysLogger.h"
22
#include "schema/pgSchema.h"
23
#include "schema/pgTable.h"
26
#include "images/backup.xpm"
29
#define nbNotebook CTRL_NOTEBOOK("nbNotebook")
30
#define txtFilename CTRL_TEXT("txtFilename")
31
#define btnFilename CTRL_BUTTON("btnFilename")
32
#define chkVerbose CTRL_CHECKBOX("chkVerbose")
35
BEGIN_EVENT_TABLE(frmBackupServer, ExternProcessDialog)
36
EVT_TEXT(XRCID("txtFilename"), frmBackupServer::OnChange)
37
EVT_BUTTON(XRCID("btnFilename"), frmBackupServer::OnSelectFilename)
38
EVT_BUTTON(wxID_OK, frmBackupServer::OnOK)
39
EVT_CLOSE( ExternProcessDialog::OnClose)
44
frmBackupServer::frmBackupServer(frmMain *form, pgObject *obj) : ExternProcessDialog(form)
48
wxWindowBase::SetFont(settings->GetSystemFont());
49
LoadResource(form, wxT("frmBackupServer"));
52
SetTitle(wxString::Format(_("Backup globals %s %s"), object->GetTranslatedTypeName().c_str(), object->GetFullIdentifier().c_str()));
55
settings->Read(wxT("frmBackupServer/LastFile"), &val, wxEmptyString);
56
txtFilename->SetValue(val);
58
if (!((pgServer *)object)->GetPasswordIsStored())
59
environment.Add(wxT("PGPASSWORD=") + ((pgServer *)object)->GetPassword());
62
SetIcon(wxIcon(backup_xpm));
64
txtMessages = CTRL_TEXT("txtMessages");
65
txtMessages->SetMaxLength(0L);
73
frmBackupServer::~frmBackupServer()
79
wxString frmBackupServer::GetHelpPage() const
82
page = wxT("pg/app-pgdumpall");
87
void frmBackupServer::OnSelectFilename(wxCommandEvent &ev)
89
wxString title, prompt, FilenameOnly;
91
title = _("Select output file");
92
prompt = _("Query files (*.sql)|*.sql|All files (*.*)|*.*");
94
wxFileName::SplitPath(txtFilename->GetValue(), NULL, NULL, &FilenameOnly, NULL);
95
wxFileDialog file(this, title, ::wxPathOnly(txtFilename->GetValue()), FilenameOnly, prompt, wxFD_SAVE);
97
if (file.ShowModal() == wxID_OK)
99
txtFilename->SetValue(file.GetPath());
105
void frmBackupServer::OnChange(wxCommandEvent &ev)
107
if (!process && !done)
108
btnOK->Enable(!txtFilename->GetValue().IsEmpty());
111
wxString frmBackupServer::GetCmd(int step)
113
wxString cmd = getCmdPart1();
115
return cmd + getCmdPart2();
119
wxString frmBackupServer::GetDisplayCmd(int step)
121
wxString cmd = getCmdPart1();
123
return cmd + getCmdPart2();
127
wxString frmBackupServer::getCmdPart1()
129
extern wxString pgBackupAllExecutable;
130
extern wxString edbBackupAllExecutable;
132
pgServer *server = (pgServer *)object;
135
if (server->GetConnection()->EdbMinimumVersion(8,0))
136
cmd=edbBackupAllExecutable;
138
cmd=pgBackupAllExecutable;
140
if (!server->GetName().IsEmpty())
141
cmd += wxT(" -h ") + server->GetName();
143
cmd += wxT(" -p ") + NumToStr((long)server->GetPort())
144
+ wxT(" -U ") + server->GetUsername();
149
wxString frmBackupServer::getCmdPart2()
152
// if (server->GetSSL())
153
// pg_dump doesn't support ssl
155
if (chkVerbose->GetValue())
156
cmd.Append(wxT(" -v"));
158
cmd.Append(wxT(" -f \"") + txtFilename->GetValue() + wxT("\""));
164
void frmBackupServer::Go()
166
txtFilename->SetFocus();
170
void frmBackupServer::OnOK(wxCommandEvent &ev)
174
if (processedFile == txtFilename->GetValue())
176
if (wxMessageBox(_("Are you sure you wish to run a backup to this file again?"), _("Repeat backup?"), wxICON_QUESTION | wxYES_NO) == wxNO)
180
processedFile = txtFilename->GetValue();
183
settings->Write(wxT("frmBackupServer/LastFile"), txtFilename->GetValue());
184
ExternProcessDialog::OnOK(ev);
187
backupServerFactory::backupServerFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar) : contextActionFactory(list)
189
mnu->Append(id, _("&Backup server..."), _("Creates a backup of the entire server"));
193
wxWindow *backupServerFactory::StartDialog(frmMain *form, pgObject *obj)
195
frmBackupServer *frm=new frmBackupServer(form, obj);
201
bool backupServerFactory::CheckEnable(pgObject *obj)
203
extern wxString pgBackupExecutable;
204
extern wxString edbBackupExecutable;
209
if (!((pgServer *)obj)->GetConnected() || obj->GetMetaType() != PGM_SERVER)
212
if (obj->GetConnection()->EdbMinimumVersion(8, 0))
213
return !edbBackupExecutable.IsEmpty() && pgAppMinimumVersion(edbBackupExecutable, 8, 3);
215
return !pgBackupExecutable.IsEmpty() && pgAppMinimumVersion(pgBackupExecutable, 8, 3);
1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: frmBackupServer.cpp 7919 2009-06-11 13:31:15Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
// frmBackupServer.cpp - Backup server dialogue
10
//////////////////////////////////////////////////////////////////////////
14
#include <wx/settings.h>
19
#include "frm/frmMain.h"
20
#include "frm/frmBackupServer.h"
21
#include "utils/sysLogger.h"
22
#include "schema/pgSchema.h"
23
#include "schema/pgTable.h"
26
#include "images/backup.xpm"
29
#define nbNotebook CTRL_NOTEBOOK("nbNotebook")
30
#define txtFilename CTRL_TEXT("txtFilename")
31
#define btnFilename CTRL_BUTTON("btnFilename")
32
#define chkVerbose CTRL_CHECKBOX("chkVerbose")
35
BEGIN_EVENT_TABLE(frmBackupServer, ExternProcessDialog)
36
EVT_TEXT(XRCID("txtFilename"), frmBackupServer::OnChange)
37
EVT_BUTTON(XRCID("btnFilename"), frmBackupServer::OnSelectFilename)
38
EVT_BUTTON(wxID_OK, frmBackupServer::OnOK)
39
EVT_CLOSE( ExternProcessDialog::OnClose)
44
frmBackupServer::frmBackupServer(frmMain *form, pgObject *obj) : ExternProcessDialog(form)
48
wxWindowBase::SetFont(settings->GetSystemFont());
49
LoadResource(form, wxT("frmBackupServer"));
52
SetTitle(wxString::Format(_("Backup globals %s %s"), object->GetTranslatedTypeName().c_str(), object->GetFullIdentifier().c_str()));
55
settings->Read(wxT("frmBackupServer/LastFile"), &val, wxEmptyString);
56
txtFilename->SetValue(val);
58
if (!((pgServer *)object)->GetPasswordIsStored())
59
environment.Add(wxT("PGPASSWORD=") + ((pgServer *)object)->GetPassword());
61
// Pass the SSL mode via the environment
62
environment.Add(wxT("PGSSLMODE=") + ((pgServer *)object)->GetConnection()->GetSslModeName());
65
SetIcon(wxIcon(backup_xpm));
67
txtMessages = CTRL_TEXT("txtMessages");
68
txtMessages->SetMaxLength(0L);
76
frmBackupServer::~frmBackupServer()
82
wxString frmBackupServer::GetHelpPage() const
85
page = wxT("pg/app-pgdumpall");
90
void frmBackupServer::OnSelectFilename(wxCommandEvent &ev)
92
wxString title, prompt, FilenameOnly;
94
title = _("Select output file");
95
prompt = _("Query files (*.sql)|*.sql|All files (*.*)|*.*");
97
wxFileName::SplitPath(txtFilename->GetValue(), NULL, NULL, &FilenameOnly, NULL);
98
wxFileDialog file(this, title, ::wxPathOnly(txtFilename->GetValue()), FilenameOnly, prompt, wxFD_SAVE);
100
if (file.ShowModal() == wxID_OK)
102
txtFilename->SetValue(file.GetPath());
108
void frmBackupServer::OnChange(wxCommandEvent &ev)
110
if (!process && !done)
111
btnOK->Enable(!txtFilename->GetValue().IsEmpty());
114
wxString frmBackupServer::GetCmd(int step)
116
wxString cmd = getCmdPart1();
118
return cmd + getCmdPart2();
122
wxString frmBackupServer::GetDisplayCmd(int step)
124
wxString cmd = getCmdPart1();
126
return cmd + getCmdPart2();
130
wxString frmBackupServer::getCmdPart1()
132
pgServer *server = (pgServer *)object;
135
if (server->GetConnection()->EdbMinimumVersion(8,0))
136
cmd=edbBackupAllExecutable;
137
else if (server->GetConnection()->GetIsGreenplum())
138
cmd=gpBackupAllExecutable;
140
cmd=pgBackupAllExecutable;
142
if (!server->GetName().IsEmpty())
143
cmd += wxT(" --host ") + server->GetName();
145
cmd += wxT(" --port ") + NumToStr((long)server->GetPort())
146
+ wxT(" --username ") + server->GetUsername();
151
wxString frmBackupServer::getCmdPart2()
155
if (settings->GetIgnoreVersion())
156
cmd.Append(wxT(" --ignore-version"));
157
if (chkVerbose->GetValue())
158
cmd.Append(wxT(" --verbose"));
160
cmd.Append(wxT(" --file \"") + txtFilename->GetValue() + wxT("\""));
166
void frmBackupServer::Go()
168
txtFilename->SetFocus();
172
void frmBackupServer::OnOK(wxCommandEvent &ev)
176
if (processedFile == txtFilename->GetValue())
178
if (wxMessageBox(_("Are you sure you wish to run a backup to this file again?"), _("Repeat backup?"), wxICON_QUESTION | wxYES_NO) == wxNO)
181
else if (wxFile::Exists(txtFilename->GetValue()))
184
msg.Printf(_("The file: \n\n%s\n\nalready exists. Do you want to overwrite it?"), txtFilename->GetValue().c_str());
185
if (wxMessageBox(msg, _("Overwrite file?"), wxICON_WARNING | wxYES_NO) == wxNO)
189
processedFile = txtFilename->GetValue();
192
settings->Write(wxT("frmBackupServer/LastFile"), txtFilename->GetValue());
193
ExternProcessDialog::OnOK(ev);
196
backupServerFactory::backupServerFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : contextActionFactory(list)
198
mnu->Append(id, _("&Backup server..."), _("Creates a backup of the entire server"));
202
wxWindow *backupServerFactory::StartDialog(frmMain *form, pgObject *obj)
204
frmBackupServer *frm=new frmBackupServer(form, obj);
210
bool backupServerFactory::CheckEnable(pgObject *obj)
215
if (!((pgServer *)obj)->GetConnected() || obj->GetMetaType() != PGM_SERVER)
218
if (obj->GetConnection()->EdbMinimumVersion(8, 0))
219
return !edbBackupExecutable.IsEmpty() && pgAppMinimumVersion(edbBackupExecutable, 8, 3);
220
else if (obj->GetConnection()->GetIsGreenplum())
221
return !gpBackupExecutable.IsEmpty() && pgAppMinimumVersion(gpBackupExecutable, 8, 3);
223
return !pgBackupExecutable.IsEmpty() && pgAppMinimumVersion(pgBackupExecutable, 8, 3);