Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 4 of 4 total |
Upload file to store |
Sun, Oct 18 2020 5:19 PM | Permanent Link |
Marcello Bachechi | Hello, I have to need to implement a way to export backups and share them with support for my end users.
How do you export/import from a store programmatically from files that are not already in the store? Thank you |
Mon, Oct 19 2020 3:19 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Marcello
You can either move them into the store programmatically (say via ShellAPI and file commands) or by the users moving them with Windows Explorer, or create a store where the files are, import/export them and then remove the store eg procedure TRestoreForm.RestoreClick(Sender: TObject); var fNam: string; begin Restore.Visible := False; GetBackup.Filter := 'Backups|*' + dm.TfRSession.LocalBackupExtension; GetBackup.FileName := dm.DB.Database + '*' + dm.TfRSession.LocalBackupExtension; GetBackup.InitialDir := GetCfgPath(cfg_BackupPath); if GetBackup.Execute then begin fNam := ExtractFileName(GetBackup.FileName); fNam := Copy(fNam, 1, LastDelimiter('.', fNam) - 1); if nlhQuestion('Are you certain you want to restore the data from ' + fNam + ' and overwrite the existing database?')then begin try dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); except end; dm.TfRSession.Execute('CREATE STORE "buTfR" AS LOCAL PATH ' + QuotedStr(ExtractFilePath(GetBackup.FileName))); Progress.Visible := True; dm.DB.Close; DoRestore.SQL.Text := 'RESTORE DATABASE ' + dm.DB.Database + ' FROM "' + fNam + '" IN STORE "buTfR" INCLUDE CATALOG'; DoRestore.ExecSQL; Progress.Visible := True; dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); end; end; Close; end; procedure TBackupForm.ActionBackupClick(Sender: TObject); var buName: string; Unique: string; Cntr: integer; buCmnd: string; TblList: string; begin ActionBackup.Visible := False; SelectNone.Visible := False; SelectAll.Visible := False; SelectQuick.Visible := False; Update; if buLocation.Text <> '' then begin if ForceDirectories(buLocation.Text) then begin try dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); except end; dm.TfRSession.Execute('CREATE STORE "buTfR" AS LOCAL PATH ' + QuotedStr(buLocation.Text)); DoBackup.Close; buName := dm.DB.Database + ' (' + dm.TfREngine.DateToSQLStr(Now) + ')'; Unique := ''; Cntr := 64; while FileExists(IncludeTrailingPathDelimiter(buLocation.Text) + buName + Unique + dm.TfRSession.LocalBackupExtension) do begin inc(Cntr); Unique := Chr(Cntr); end; buName := buName + Unique; buCmnd := 'BACKUP DATABASE ' + dm.DB.Database + ' AS "' + buName + '" TO STORE "buTfR" TABLES '; TblList := ''; for Cntr := 0 to Tables.Items.Count - 1 do begin if Tables.Checked[Cntr] then TblList := TblList + Tables.Items[Cntr] + ', '; end; Delete(TblList, Length(TblList) - 1, 2); buCmnd := buCmnd + TblList; buCmnd := buCmnd + ' INCLUDE CATALOG'; DoBackup.SQL.Text := buCmnd; Progress.Visible := True; DoBackup.ExecSQL; dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); Close; end else nlhMessageDlg('Directory does not exist and unable to create it.', ntError); end else nlhMessageDlg('No backup location identified', ntError); end; Roy Lambert |
Mon, Oct 19 2020 2:13 PM | Permanent Link |
Marcello Bachechi | Roy, thank you for your response. Is there a way to accomplish this without creating a new store?
Roy Lambert wrote: Marcello You can either move them into the store programmatically (say via ShellAPI and file commands) or by the users moving them with Windows Explorer, or create a store where the files are, import/export them and then remove the store eg procedure TRestoreForm.RestoreClick(Sender: TObject); var fNam: string; begin Restore.Visible := False; GetBackup.Filter := 'Backups|*' + dm.TfRSession.LocalBackupExtension; GetBackup.FileName := dm.DB.Database + '*' + dm.TfRSession.LocalBackupExtension; GetBackup.InitialDir := GetCfgPath(cfg_BackupPath); if GetBackup.Execute then begin fNam := ExtractFileName(GetBackup.FileName); fNam := Copy(fNam, 1, LastDelimiter('.', fNam) - 1); if nlhQuestion('Are you certain you want to restore the data from ' + fNam + ' and overwrite the existing database?')then begin try dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); except end; dm.TfRSession.Execute('CREATE STORE "buTfR" AS LOCAL PATH ' + QuotedStr(ExtractFilePath(GetBackup.FileName))); Progress.Visible := True; dm.DB.Close; DoRestore.SQL.Text := 'RESTORE DATABASE ' + dm.DB.Database + ' FROM "' + fNam + '" IN STORE "buTfR" INCLUDE CATALOG'; DoRestore.ExecSQL; Progress.Visible := True; dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); end; end; Close; end; procedure TBackupForm.ActionBackupClick(Sender: TObject); var buName: string; Unique: string; Cntr: integer; buCmnd: string; TblList: string; begin ActionBackup.Visible := False; SelectNone.Visible := False; SelectAll.Visible := False; SelectQuick.Visible := False; Update; if buLocation.Text <> '' then begin if ForceDirectories(buLocation.Text) then begin try dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); except end; dm.TfRSession.Execute('CREATE STORE "buTfR" AS LOCAL PATH ' + QuotedStr(buLocation.Text)); DoBackup.Close; buName := dm.DB.Database + ' (' + dm.TfREngine.DateToSQLStr(Now) + ')'; Unique := ''; Cntr := 64; while FileExists(IncludeTrailingPathDelimiter(buLocation.Text) + buName + Unique + dm.TfRSession.LocalBackupExtension) do begin inc(Cntr); Unique := Chr(Cntr); end; buName := buName + Unique; buCmnd := 'BACKUP DATABASE ' + dm.DB.Database + ' AS "' + buName + '" TO STORE "buTfR" TABLES '; TblList := ''; for Cntr := 0 to Tables.Items.Count - 1 do begin if Tables.Checked[Cntr] then TblList := TblList + Tables.Items[Cntr] + ', '; end; Delete(TblList, Length(TblList) - 1, 2); buCmnd := buCmnd + TblList; buCmnd := buCmnd + ' INCLUDE CATALOG'; DoBackup.SQL.Text := buCmnd; Progress.Visible := True; DoBackup.ExecSQL; dm.TfRSession.Execute('DROP STORE "buTfR" KEEP CONTENTS'); Close; end else nlhMessageDlg('Directory does not exist and unable to create it.', ntError); end else nlhMessageDlg('No backup location identified', ntError); end; Roy Lambert |
Tue, Oct 20 2020 7:46 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Marcello
<<Is there a way to accomplish this without creating a new store?>> Not that I know of using ElevateDB functions since ElevateDB requires a store to process import / export. The only way to avoid a store would be to write your own routines in Delphi, but since a store just points to a directory I dion't see a problem. Roy Lambert |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |