Recover postgreSQL databases from raw physical files

后端 未结 6 1675
走了就别回头了
走了就别回头了 2020-12-23 17:28

I have the following problem and I need to know if there´s a way to fix it.

I have a client who was cheap enough to decline buying a backup plan for his postgreSQL d

6条回答
  •  暖寄归人
    2020-12-23 17:45

    The question is very old, but I want to share an effective method that I found.

    If you have not got a backup with "pg_dump" and your old data is folder, try the following steps. In the Postgres database, add records to the "pg_database" table. With a manager program or "insert into". Make the necessary check and change the following insert query and run it.

    The query will return an OID after it has worked. Create a folder with the name of this number. Once you have copied your old data into this folder, the use is now ready.

    
    
        /*
        ------------------------------------------
        *** Recover From Folder ***
        ------------------------------------------
        Check this table on your own system.
        Change the differences below.
        */
        INSERT INTO
          pg_catalog.pg_database(
          datname, datdba, encoding, datcollate, datctype, datistemplate, datallowconn,
          datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl)
        VALUES(
                                 -- Write Your collation  
          'NewDBname', 10, 6, 'Turkish_Turkey.1254', 'Turkish_Turkey.1254',
          False, True, -1, 12400, '536', '1', 1663, Null);
    
        /*
        Create a folder in the Data directory under the name below New OID.
        All old backup files in the directory "data\base\Old OID" are the directory with the new OID number
        Copy. The database is now ready for use.
        */
        select oid from pg_database a where a.datname = 'NewDBname';
    
    

提交回复
热议问题