IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bases de données Delphi Discussion :

Backup Restore Firebird


Sujet :

Bases de données Delphi

  1. #1
    Membre éprouvé Avatar de defluc
    Homme Profil pro
    Architecte
    Inscrit en
    Mai 2002
    Messages
    1 383
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 383
    Points : 1 199
    Points
    1 199
    Par défaut Backup Restore Firebird
    Bonjour,

    Sur la page http://www.ibphoenix.fr/article.php3?id_article=12, Philippe Makowski nous fournit un fichier batch exécutant Backup/Restore.

    Si on exécute ce fichier à l'intérieur d'une application Delphi par une instruction WinExec, est-il possible de récupérer les messages d'erreur renvoyés par les instructions «Echo» du fichier batch.

    Autrement dit, comment exécuter une à une les instructions dans l'application Delphi en y gérant les erreurs.

  2. #2
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Salut Defluc.

    Si tu cherches à intercepter un ErrorLevel (DOS) depuis ton appli Delphi, là franchement je ne sais pas si c'est possible.

    Mais le batch, fournit par Philippe, alimente un fichier log. Pourquoi ne pas afficher ce log dans un memo dès le retour de WinExec?

    @+ Claudius

  3. #3
    Membre éprouvé Avatar de defluc
    Homme Profil pro
    Architecte
    Inscrit en
    Mai 2002
    Messages
    1 383
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 383
    Points : 1 199
    Points
    1 199
    Par défaut
    Merci de ta réponse.
    Cela n'aidera pas l'utilisateur non initié si le backup/restore échoue à l'une de ses étapes.
    Je voudrais qu'il puisse cliquer un bouton qui exécute le backup/restore et lui affiche un message le gfix si celui-ci a échoué, puis après le backup et enfin idem après le restore.
    A ce moment, il pourrait réessayer et alerter le responsable de l'application en cas d'échec répété.
    Je pense avoir trouvé ici http://delphi.newswhat.com/geoxml/fo...ps.borland.com une piste mais quant à la mettre en oeuvre, je reste perplexe

  4. #4
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 036
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 036
    Points : 40 941
    Points
    40 941
    Billets dans le blog
    62
    Par défaut
    et pourquoi pas plusieurs petits batch imbriqués

    se casser la tête des fois !!!!!!!!
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  5. #5
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Re,

    Un truc dans ce genre là !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
     
    const
      GFIXNameWithFullPath = 'C:\Program files\Firebird\Firebird_2_0\bin\gfix.exe';
      GBAKNameWithFullPath = 'C:\Program files\Firebird\Firebird_2_0\bin\gbak.exe';
     
      ShutDownParamList = '-shut -attach 30 C:\DataBases\Firebird\Test_FB2.fdb -user SYSDBA -pass masterkey';
      OnLineParamList = '-online C:\DataBases\Firebird\Test_FB2.fdb -user SYSDBA -pass masterkey';
      BackupParamlist = '-B -T -user SYSDBA -pass masterkey C:\DataBases\Firebird\Test_FB2.fdb C:\DataBases\Firebird\Test_FB2.fbk';
      RestoreParamList = '-REPLACE_DATABASE -user SYSDBA -pass masterkey -p 4096 C:\DataBases\Firebird\Test_FB2.fbk C:\DataBases\Firebird\Test_FB2.fdb';
     
    implementation
     
    {$R *.dfm}
    uses
      ShellAPI;
     
    function LaunchExe(ExeName, ParamList: string): Boolean;
    var
      exInfo: TShellExecuteInfo;
      exitcode: DWORD;
    begin
      result := False;
     
      FillChar( exInfo, Sizeof(exInfo), 0 );
      with exInfo Do Begin
        cbSize:= Sizeof( exInfo ); // required!
        fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
        Wnd   := Form1.Handle;  // forms handle
        lpVerb:= 'open';
        lpFile:= Pchar( ExeName );
        lpParameters := PChar( Paramlist );
        nShow := SW_HIDE;
      End;
      if ShellExecuteEx( @exInfo ) Then Begin
        While GetExitCodeProcess( exinfo.hProcess, exitcode ) and
              (exitcode = STILL_ACTIVE)
        Do
          Sleep( 500 );
        CloseHandle( exInfo.hProcess );
     
        if exitcode <> 0 then
          ShowMessage('Echec Code ' + IntToStr(exitCode))
        else
          result := True;
      End
      Else
        ShowMessage(SysErrorMessage( GetLastError ));
    end;
     
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if not LaunchExe(GFIXNameWithFullPath, ShutdownParamlist) then Exit;
      if not LaunchExe(GBAKNameWithFullPath, BackupParamlist) then Exit;
      if not LaunchExe(GBAKNameWithFullPath, RestoreParamlist) then Exit;
      LaunchExe(GFIXNameWithFullPath, OnlineParamlist);
    end;
     
    end.
    @+ Claudius

  6. #6
    Membre éprouvé Avatar de defluc
    Homme Profil pro
    Architecte
    Inscrit en
    Mai 2002
    Messages
    1 383
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 383
    Points : 1 199
    Points
    1 199
    Par défaut
    Ca m'a l'air super, Cl@udius

    J'essaierai dès ce soir et je vous tiens au courant.
    Je suis étonné que cela n'ai pas encore été développé parce que c'est intéressant, voire incontournable, dans une application Delohi/Firebird.

  7. #7
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Cela dépend des compos que tu utilises.
    La suite des compos UIB, possèdent les compos Backup, Restore et Repair (que je n'ai pas encore utilisé) mais qui m'ont l'air intéressant.

    Citation Envoyé par defluc
    Je suis étonné que cela n'ai pas encore été développé parce que c'est intéressant, voire incontournable, dans une application Delohi/Firebird.
    Ce n'est pas non plus systèmatiquement le rôle d'une application cliente que de faire de l'administration sur une base !


    @+

  8. #8
    Membre éprouvé Avatar de defluc
    Homme Profil pro
    Architecte
    Inscrit en
    Mai 2002
    Messages
    1 383
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte

    Informations forums :
    Inscription : Mai 2002
    Messages : 1 383
    Points : 1 199
    Points
    1 199
    Par défaut
    Bonjour

    Ca marche.

    Après adaptation à mon application, le code devient
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    function LaunchExe(ExeName, ParamList: string): Boolean;
    var
      exInfo: TShellExecuteInfo;
      exitcode: DWORD;
    begin
      result := False;
      FillChar( exInfo, Sizeof(exInfo), 0 );
      with exInfo Do Begin
        cbSize:= Sizeof( exInfo ); // required!
        fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
        Wnd   := MainForm.Handle;  // forms handle
        lpVerb:= 'open';
        lpFile:= Pchar(ExeName);
        lpParameters := PChar( Paramlist );
        nShow := SW_HIDE;
      End;
      if ShellExecuteEx( @exInfo ) Then
      Begin
        While GetExitCodeProcess( exinfo.hProcess, exitcode ) and
              (exitcode = STILL_ACTIVE) Do Sleep( 500 );
        CloseHandle( exInfo.hProcess );
        if exitcode <> 0 then
          ShowMessage('Error ' + IntToStr(exitCode) + ' in '#13 +
                      ExeName + ' ' + ParamList + #13#13 +
                      'Execution is halted.')
                         else
          result := True;
      End
                                   Else
        ShowMessage(SysErrorMessage( GetLastError ));
    end;
     
    procedure TMainForm.DbCompactButtonClick(Sender: TObject);
    Var
      GFIXNameWithFullPath : String;
      GBAKNameWithFullPath : String;
      ShutDownParamList : String;
      OnLineParamList : String;
      BackupParamlist : String;
      RestoreParamList : String;
     
    begin
      GFIXNameWithFullPath := CurDir + 'bin\gfix.exe';
      GBAKNameWithFullPath := CurDir + 'bin\gbak.exe';
      ShutDownParamList := '-shut -attach 30 ' + CurDir + 'CadaCom.fdb -user SYSDBA -pass masterkey';
      OnLineParamList := '-online ' + CurDir + 'CadaCom.fdb -user SYSDBA -pass masterkey';
      BackupParamlist := '-B -T -user SYSDBA -pass masterkey ' + CurDir + 'CadaCom.fdb ' + CurDir + 'CadaCom.fbk';
      RestoreParamList := '-REPLACE_DATABASE -user SYSDBA -pass masterkey -p 4096 ' + CurDir + 'CadaCom.fbk ' + CurDir + 'CadaCom.fdb' ;
      if not LaunchExe(GFIXNameWithFullPath, ShutdownParamlist) then Exit;
      if not LaunchExe(GBAKNameWithFullPath, BackupParamlist) then Exit;
      if not LaunchExe(GBAKNameWithFullPath, RestoreParamlist) then Exit;
      LaunchExe(GFIXNameWithFullPath, OnlineParamlist);
    end;
    Seul hic, une erreur 1 au
    gbak.exe -REPLACE_DATABASE -user SYSDBA -pass masterkey -p 4096 ...

  9. #9
    Membre habitué
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Janvier 2007
    Messages
    221
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 221
    Points : 185
    Points
    185
    Par défaut
    bonjours

    le code est super , mais j' ai error 1 sur gfix
    question error 1 ?

Discussions similaires

  1. Configurer machine linux pour backup/restore
    Par Sendo dans le forum Administration système
    Réponses: 3
    Dernier message: 12/05/2006, 13h43
  2. Demande de précisions sur Backup/Restore et transactions
    Par lio33 dans le forum Connexion aux bases de données
    Réponses: 1
    Dernier message: 16/11/2005, 12h08
  3. Y a t'il un composant pour le backup de Firebird?
    Par Harry dans le forum Bases de données
    Réponses: 20
    Dernier message: 11/07/2005, 10h39
  4. interbase - grant - backup/restore
    Par frantzgac dans le forum InterBase
    Réponses: 2
    Dernier message: 22/04/2005, 13h21
  5. Too Many versions & Backup-Restore à rallonge
    Par Harry dans le forum Administration
    Réponses: 14
    Dernier message: 30/06/2004, 18h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo