Backup and restore

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • datactrl
    New Member
    • Jul 2008
    • 51

    Backup and restore

    Can I back up all stored procedures and triggers on a database?
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    What about pg_dump
    pg_dump pg_dump — export a PostgreSQL database as an SQL script or to other formats Synopsis pg_dump [connection-option...] [option...] [dbname] …

    Comment

    • datactrl
      New Member
      • Jul 2008
      • 51

      #3
      Thank you for your suggestion,rski . I did read the pg_dump document. Just can't find exact way to do it. Finally I figure out such as following.
      "pg_dump -T *.* mydb >mydb.sql"

      Well which will produce a script. After delete schema creation statements and replace "create function" with "create and replace function", it becomes exactly what I needed. I'm a developer. I used a lot of stored procedures in my application for customers. After a version update, I need to upgrade customer's database without touch their data. It will be too hard to pick up every updated sp to upgrade. Instead, I think the easy way to do is just reinstall all sp. That's why I need the exact way to backup all sp.

      Comment

      • rski
        Recognized Expert Contributor
        • Dec 2006
        • 700

        #4
        Don't you keep you stored procedures in a files (probably in some versioning system like cvs)?
        If you do, I do not understand why do you want to get sp definitions from database?

        But if you need that i think you need to write a script that will go through pg_proc table and read sp definitions.

        Comment

        • datactrl
          New Member
          • Jul 2008
          • 51

          #5
          versioning system

          Thank you for reply. Would you be able to recommend a simple versioning system? Thank you again!

          Comment

          • rski
            Recognized Expert Contributor
            • Dec 2006
            • 700

            #6
            The most popular I think are CVS, SVN and GIT

            Comment

            Working...