meta données pour cette page
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| postgresql:restoredb [26/01/2026 15:25] – mdl | postgresql:restoredb [06/02/2026 13:18] (Version actuelle) – mdl | ||
|---|---|---|---|
| Ligne 4: | Ligne 4: | ||
| <code BASH> | <code BASH> | ||
| [postgres@postgre1 ~]$ mkdir -p / | [postgres@postgre1 ~]$ mkdir -p / | ||
| + | </ | ||
| + | |||
| + | * création user applicatif | ||
| + | <code BASH> | ||
| + | CREATE USER dvdrental with NOSUPERUSER, | ||
| + | </ | ||
| + | |||
| + | * création schéma dédié | ||
| + | <code BASH> | ||
| + | CREATE SCHEMA IF NOT EXISTS s_db_dvdrental AUTHORIZATION dvdrental ; | ||
| + | </ | ||
| + | |||
| + | |||
| + | * tablespace dedié | ||
| + | <code BASH> | ||
| + | create tablespace tbs_dvdrental_1 location '/ | ||
| + | |||
| + | dvdrental=# \db | ||
| + | Liste des tablespaces | ||
| + | Nom | Propriétaire | Emplacement | ||
| + | ----------------+--------------+--------------------------- | ||
| + | tbs_dvdrental_1 | postgres | ||
| + | | ||
| + | | ||
| + | (3 lignes) | ||
| + | |||
| </ | </ | ||
| Ligne 9: | Ligne 35: | ||
| <code BASH> | <code BASH> | ||
| psql -U postgres | psql -U postgres | ||
| - | CREATE DATABASE | + | CREATE DATABASE |
| </ | </ | ||
| - | * tablespace dedié | + | * assigner schema à la nouvelle BDD |
| <code BASH> | <code BASH> | ||
| - | postgres=# \connect dvdrental | + | ALTER DATABASE db_dvdrental SET search_path TO s_db_dvdrental |
| - | dvdrental=# create tablespace dvdrental_data location '/ | + | |
| </ | </ | ||
| + | |||
| + | |||
| + | * création role dédié DB Owner | ||
| + | <code BASH> | ||
| + | create role r_db_dvdrental_owner; | ||
| + | </ | ||
| + | |||
| + | * on donne tous les privilèges au role sur la BDD | ||
| + | <code BASH> | ||
| + | grant ALL PRIVILEGES ON DATABASE db_dvdrental to r_db_dvdrental_owner; | ||
| + | </ | ||
| + | |||
| + | * on ajoute le user applicatif à ce role | ||
| + | <code BASH> | ||
| + | grant dvdrental to r_db_dvdrental_owner; | ||
| + | </ | ||
| + | |||
| + | * Lister le contenu du backup | ||
| + | <code BASH> | ||
| + | postgres@postgre1 Downloads]$ pg_restore -l dvdrental.tar | ||
| + | ; | ||
| + | ; Archive created at 2019-05-12 11:36:37 CEST | ||
| + | ; | ||
| + | ; TOC Entries: 144 | ||
| + | ; | ||
| + | ; Dump Version: 1.13-0 | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; 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, | ||
| + | 232; 1255 16737 FUNCTION public film_in_stock(integer, | ||
| + | 233; 1255 16738 FUNCTION public film_not_in_stock(integer, | ||
| + | [...] | ||
| + | 2910; 2606 17039 FK CONSTRAINT public store store_manager_staff_id_fkey postgres | ||
| + | </ | ||
| + | |||
| + | * restore sur la BDD précédemment crée | ||
| + | <code BASH> | ||
| + | pg_restore -U postgres -d dvdrental --verbose dvdrental.tar -j 2 | ||
| + | </ | ||
| + | |||