Backup/Restore PostgreSQL databases

View: 1285    Dowload: 0   Comment: 0   Post by: naruto  
Author: none   Category: PostgreSQL   Fields: Computers - Technology

0 point/3 review File has been tested

Download   backup-restore-postgresql.rar (3.58 MB)

You need to Sign In to download the file backup-restore-postgresql.rar
If you do not have an account then Sign up for free here

Download error   Report copyright violation

This article provides developers the possibility to quick implement « Backup/Restore database » functionality in their applications. This library can be used from your application, and the backup operation runs in the local machine. It is not necessary to run backup or restore on the server.

Introduction

This article provides developers the possibility to quick implement « Backup/Restore database » functionality in their applications. This library can be used from your application, and the backup operation runs in the local machine. It is not necessary to run backup or restore on the server.

Background

This library use some PostgreSQL files:

  • pg_dump.exe
  • pg_restore.exe
  • libeay32.dll
  • libiconv-2.dll
  • libintl-8.dll
  • libpq.dll
  • Npgsql.dll
  • ssleay32.dll
  • zlib1.dll

In our case this solution is tested on PostgreSQL 9.1. So if you have to use a different version, may be you need to replace files with the correct version which could be found on your PostgreSQL installation directory.

The backup/restore operation is launched in NoShell mode and the result of the execution is intercepted in an Output event which provides an output string.

Using the code

To launch Backup or Restore operation, you have to fill a config object that contains the host, username, port, and password. All public methods are written in a static class named Control.

To start backup, use the method below:

//
void BackUp()
{
    pgstore.Config cnf = new Config();
    cnf.ServerName = txtHost.Text;
    if (lstDB.Items.Count > 0 && lstDB.SelectedItem!=null)
        cnf.DataBase = lstDB.SelectedItem.ToString();
    cnf.UserName = txtUserName.Text;
    cnf.Password = txtPass.Text;
    cnf.Port = Convert.ToInt16(txtPort.Text);
    pgstore.Control.CurrentConfig = cnf;
    string FileName = pgstore.Control.CurrentConfig.DataBase + "_" + DateTime.Now.Day.ToString() + 
      "_" + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + ".backup";
    pgstore.Control.Backup("D:\backup" , FileName, true);
}//

To start restore, use the method below:

//
void Restore(string path)
{
    pgstore.Config cnf = new Config();
    cnf.ServerName = txtHost.Text;
    if (lstDB.Items.Count > 0 && lstDB.SelectedItem!=null)
        cnf.DataBase = lstDB.SelectedItem.ToString();
    cnf.UserName = txtUserName.Text;
    cnf.Password = txtPass.Text;
    cnf.Port = Convert.ToInt16(txtPort.Text);
    pgstore.Control.CurrentConfig = cnf;
    pgstore.Control.Restaure(path, false);
}

If you have a specific option, the right way is to change it in the StoreParameters object in your CurrentConfig.Parametres.

Don’t forget to add the required PostgreSQL files to your setup project.

License

This article, along with any associated source code and files, is licensed under http://www.codeproject.com/info/cpol10.aspx

Backup/Restore PostgreSQL databases

Backup/Restore PostgreSQL databases Posted on 21-03-2014  This article provides developers the possibility to quick implement « Backup/Restore database » functionality in their applications. This library can be used from your application, and the backup operation runs in the local machine. It is not necessary to run backup or restore on the server. 5/10 1285

Comment:

To comment you must be logged in members.

Files with category

  • Accessing: MySQL Database using MySQL C API

    View: 2490    Download: 2   Comment: 0   Author: none  

    Accessing: MySQL Database using MySQL C API

    Category: PostgreSQL
    Fields: Other

    0.75/6 review
    This article was written for beginners, developers that do not know how to access MySql database using MySQL C API and would like to have a small introduction.

  • Full Database Abstraction Layer Generator

    View: 2560    Download: 0   Comment: 0   Author: none  

    Full Database Abstraction Layer Generator

    Category: PostgreSQL
    Fields: Other

    0/23 review
    This article presents yet another Data Abstraction Layer generator (popular topic). The DAL structure is directly inspired from the DotNetNuke, DAL document and the SQL generation is done using SQLpp. The generator takes care of pretty much...

  • Code .NET 2.0; Build Java; Run Linux

    View: 2074    Download: 0   Comment: 0   Author: none  

    Code .NET 2.0; Build Java; Run Linux

    Category: PostgreSQL
    Fields: Other

    1.5/3 review
    This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers. This is a showcase review for...

  • Postgres Database Backup/Restore From C#

    View: 2989    Download: 3   Comment: 0   Author: none  

    Postgres Database Backup/Restore From C#

    Category: PostgreSQL
    Fields: Other

    0/10 review
    This article provides Postgres database backup/restore functionality. By using this application we can check whether a Postgres database is installed or not in a system. If a Postgres database is installed then the Postgres databases list is...

  • Installing Redmine on Windows in production

    View: 5498    Download: 0   Comment: 0   Author: none  

    Installing Redmine on Windows in production

    Category: PostgreSQL
    Fields: Other

    0/10 review
    This is a very simple step by step guide to install Redmine on Windows server in production. This guide is applicable to IIS 7+ based servers, which include Windows Server 2008, 2008 R2, Windows Vista and Windows 7. Latter two should not be used for...

  • A SQL Management Console for MSSQL 2000 & 2005, MySQL 5.0,...

    View: 3313    Download: 2   Comment: 0   Author: none  

    A SQL Management Console for MSSQL 2000 & 2005, MySQL 5.0,...

    Category: PostgreSQL
    Fields: Other

    0.5625/8 review
    Since MSSQL is not holding the lion share of the market yet, integration/interaction with other RDBMS like PL/Oracle, MySQL, FireBird, DB2, is inevitable. With the class System.Data.Common in ADO .NET 2.0, different data providers can write the...

  • Creating an Interactive Map in ASP.NET 2.0 Using SharpMap

    View: 4429    Download: 5   Comment: 0   Author: none  

    Creating an Interactive Map in ASP.NET 2.0 Using SharpMap

    Category: PostgreSQL
    Fields: Other

    0/2 review
    Showing maps on the web is becoming more and more common. The most well-known ones are Google Maps and Microsoft's Virtual Earth. Creating your own websites with interactive maps require you to get hold on the map-data and convert this data to...

  • DevShot - Database Snapshots for Developers

    View: 978    Download: 0   Comment: 0   Author: none  

    DevShot - Database Snapshots for Developers

    Category: PostgreSQL
    Fields: Other

    0/2 review
    A few weeks back, I got an idea of writing a simple tool for switching database states between coding cycles. I thought this would be a good tool for anyone who is working on database related projects and have to switch between database states since...

 

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd