meta données pour cette page
Restore DB
- arborescence dédiée
[postgres@postgre1 ~]$ mkdir -p /u02/pgsql/data/dvdrental
- création user applicatif
CREATE USER dvdrental with NOSUPERUSER,LOGIN,ENCRYPTED PASSWORD 'your_password';
- création schéma dédié
CREATE SCHEMA IF NOT EXISTS s_db_dvdrental AUTHORIZATION dvdrental ;
- tablespace dedié
create tablespace tbs_dvdrental_1 location '/u02/pgsql/data/dvdrental'; dvdrental=# \db Liste des tablespaces Nom | Propriétaire | Emplacement ----------------+--------------+--------------------------- tbs_dvdrental_1 | postgres | /u02/pgsql/data/dvdrental pg_default | postgres | pg_global | postgres | (3 lignes)
- création DB
psql -U postgres CREATE DATABASE db_dvdrental TABLESPACE 'tbs_dvdrental_1' ;
- assigner schema à la nouvelle BDD
ALTER DATABASE db_dvdrental SET search_path TO s_db_dvdrental ;
- création role dédié DB Owner
create role r_db_dvdrental_owner;
- on donne tous les privilèges au role sur la BDD
grant ALL PRIVILEGES ON DATABASE db_dvdrental to r_db_dvdrental_owner;
- on ajoute le user applicatif à ce role
grant dvdrental to r_db_dvdrental_owner;
- Lister le contenu du backup
postgres@postgre1 Downloads]$ pg_restore -l dvdrental.tar ; ; Archive created at 2019-05-12 11:36:37 CEST ; dbname: dvdrental ; TOC Entries: 144 ; Compression: none ; Dump Version: 1.13-0 ; Format: TAR ; Integer: 4 bytes ; Offset: 8 bytes ; Dumped from database version: 11.3 ; Dumped by pg_dump version: 11.2 ; ; ; Selected TOC Entries: ; 632; 1247 16723 TYPE public mpaa_rating postgres 635; 1247 16734 DOMAIN public year postgres 231; 1255 16736 FUNCTION public _group_concat(text, text) postgres 232; 1255 16737 FUNCTION public film_in_stock(integer, integer) postgres 233; 1255 16738 FUNCTION public film_not_in_stock(integer, integer) postgres [...] 2910; 2606 17039 FK CONSTRAINT public store store_manager_staff_id_fkey postgres
- restore sur la BDD précédemment crée
pg_restore -U postgres -d dvdrental --verbose dvdrental.tar -j 2