Click here to Skip to main content
15,881,559 members
Articles / Programming Languages / C#

Backup/Restore PostgreSQL databases

Rate me:
Please Sign up or sign in to vote.
4.50/5 (5 votes)
5 Mar 2013CPOL1 min read 33.1K   4.5K   10  
Allow your applications the ability to backup and restore your PostgreSQL databases.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace pgstore
{
    /// <summary>
    /// This class is used to indicate parameters used to launch pg_dump aund pg_restore commnds
    /// the parameters are initialized with the most common parameters
    /// its could be changed if necessary to do a specific tasks
    /// </summary>
    public class StoreParameters
    {
        public StoreParameters()
        {
            DataOnly = false;
            Blobs = true;
            Clean = false;      
            Oids = false;
            NoOwner = false;
            SchemaOnly = false;
            NoPrivileges = false;
    
        }
        public bool DataOnly { get; set; }
        public bool Blobs { get; set; }
        public bool Clean { get; set; }    
        public bool Oids { get; set; }
        public bool NoOwner { get; set; }
        public bool SchemaOnly { get; set; }
        public bool NoPrivileges { get; set; }
 

        public string DataOnlyCode { get { if (DataOnly)  return " -a"; return ""; } }
        public string BlobsCode { get { if (Blobs) return " -b"; return ""; } }
        public string CleanCode { get { if (Clean && !DataOnly)   return " -c"; return ""; } } 
        public string OidsCode { get { if (Oids) return " -o"; return ""; } }
        public string NoOwnerCode { get { if (NoOwner) return " -O"; return ""; } }
        public string SchemaOnlyCode { get { if (SchemaOnly) return " -s"; return ""; } }
        public string NoPrivilegesCode { get { if (NoPrivileges) return " -x"; return ""; } }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) B&B
Tunisia Tunisia
Microsoft DOTNET developer
VOIP Technologies
ERP Petales

http://www.declaration.tn/

Comments and Discussions