etalab / transport-site

Rendre disponible, valoriser et améliorer les données transports
https://transport.data.gouv.fr
184 stars 28 forks source link

restore_db: version portable sur MacOSX #3965

Closed ptitfred closed 1 month ago

ptitfred commented 1 month ago

getopt ne supporte pas les options longues sur Mac.

Ce patch réimplemente le comportement dans le parsing d'arguments.

Fixes #3962.

ptitfred commented 1 month ago

@thbar quand tu auras un moment de répis, n'hésite pas à tester sur ta machine.

thbar commented 1 month ago

@thbar quand tu auras un moment de répis, n'hésite pas à tester sur ta machine.

J'ai testé ce soir, voici l'output:

transport-site on  portable-restore-db [$+] via 🐳 desktop-linux via 💧 v1.16.2 (OTP 25) 
❯ ./restore_db.sh ../backups/postgresql_4a305f24-8a31-4815-b2bb-23f4711303ee-20240603034125.dump
pg_restore: error: could not execute query: ERROR:  extension "plv8" does not exist
Command was: DROP EXTENSION plv8;
pg_restore: error: could not execute query: ERROR:  extension "plls" does not exist
Command was: DROP EXTENSION plls;
pg_restore: error: could not execute query: ERROR:  extension "plcoffee" does not exist
Command was: DROP EXTENSION plcoffee;
pg_restore: error: could not execute query: ERROR:  could not open extension control file "/Applications/Postgres.app/Contents/Versions/14/share/postgresql/extension/plcoffee.control": No such file or directory
Command was: CREATE EXTENSION IF NOT EXISTS plcoffee WITH SCHEMA pg_catalog;

pg_restore: error: could not execute query: ERROR:  extension "plcoffee" does not exist
Command was: COMMENT ON EXTENSION plcoffee IS 'PL/CoffeeScript (v8) trusted procedural language';

pg_restore: error: could not execute query: ERROR:  could not open extension control file "/Applications/Postgres.app/Contents/Versions/14/share/postgresql/extension/plls.control": No such file or directory
Command was: CREATE EXTENSION IF NOT EXISTS plls WITH SCHEMA pg_catalog;

pg_restore: error: could not execute query: ERROR:  extension "plls" does not exist
Command was: COMMENT ON EXTENSION plls IS 'PL/LiveScript (v8) trusted procedural language';

pg_restore: error: could not execute query: ERROR:  could not open extension control file "/Applications/Postgres.app/Contents/Versions/14/share/postgresql/extension/plv8.control": No such file or directory
Command was: CREATE EXTENSION IF NOT EXISTS plv8 WITH SCHEMA pg_catalog;

pg_restore: error: could not execute query: ERROR:  extension "plv8" does not exist
Command was: COMMENT ON EXTENSION plv8 IS 'PL/JavaScript (v8) trusted procedural language';

pg_restore: warning: errors ignored on restore: 9
Truncating contact table
NOTICE:  truncate cascades to table "contacts_organizations"
NOTICE:  truncate cascades to table "dataset_followers"
NOTICE:  truncate cascades to table "notification_subscription"
NOTICE:  truncate cascades to table "user_feedback"
TRUNCATE TABLE
Truncating user_feedback table
TRUNCATE TABLE
Truncating oban_jobs table
TRUNCATE TABLE

transport-site on  portable-restore-db [$+] via 🐳 desktop-linux via 💧 v1.16.2 (OTP 25) took 7m31s 
❯ ./restore_db.sh                                                                               
Usage:
 ./restore_db.sh (-h|--help)
 ./restore_db.sh [--skip-extensions] [--preserve-oban-jobs] (--) <absolute_path_to_backup>
 ./restore_db.sh [--skip-extensions] [--preserve-oban-jobs] (--) <db_name> <host> <user_name> <password> <absolute_path_to_backup>

Ça semble fonctionner, merci pour le correctif !