From ccec3f2e4f710955fd2730904ccbd65302fc15e8 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sun, 24 Jun 2018 09:41:33 +0300 Subject: [PATCH] Add notes for 2018-06-24 --- content/posts/2018-06.md | 16 ++++++++++++++++ docs/2018-06/index.html | 25 ++++++++++++++++++++++--- docs/robots.txt | 2 +- docs/sitemap.xml | 20 ++++++++++---------- 4 files changed, 49 insertions(+), 14 deletions(-) diff --git a/content/posts/2018-06.md b/content/posts/2018-06.md index 12a6d2303..9ccca5ae0 100644 --- a/content/posts/2018-06.md +++ b/content/posts/2018-06.md @@ -227,4 +227,20 @@ UPDATE 1 - I uploaded the twenty-four reports to the IWMI Reports collection: https://cgspace.cgiar.org/handle/10568/36188 - I uploaded the seventy-six book chapters to the IWMI Book Chapters collection: https://cgspace.cgiar.org/handle/10568/36178 +## 2018-06-24 + +- I was restoring a PostgreSQL dump on my test machine and found a way to restore the CGSpace dump as the `postgres` user, but have the owner of the schema be the `dspacetest` user: + +``` +$ dropdb -h localhost -U postgres dspacetest +$ createdb -h localhost -U postgres -O dspacetest --encoding=UNICODE dspacetest +$ psql -h localhost -U postgres dspacetest -c 'alter user dspacetest superuser;' +$ pg_restore -h localhost -U postgres -d dspacetest -O --role=dspacetest -W -h localhost /tmp/cgspace_2018-06-24.backup +$ psql -h localhost -U postgres dspacetest -c 'alter user dspacetest nosuperuser;' +``` + +- The `-O` option to `pg_restore` makes the import process ignore ownership specified in the dump itself, and instead makes the schema owned by the user doing the restore +- I always prefer to use the `postgres` user locally because it's just easier than remembering the `dspacetest` user's password, but then I couldn't figure out why the resulting schema was owned by `postgres` +- So with this you connect as the `postgres` superuser and then switch roles to `dspacetest` (also, make sure this user has `superuser` privileges before the restore) + diff --git a/docs/2018-06/index.html b/docs/2018-06/index.html index 2fdb5cdae..3e34d1467 100644 --- a/docs/2018-06/index.html +++ b/docs/2018-06/index.html @@ -41,7 +41,7 @@ sys 2m7.289s - + @@ -93,9 +93,9 @@ sys 2m7.289s "@type": "BlogPosting", "headline": "June, 2018", "url": "https://alanorth.github.io/cgspace-notes/2018-06/", - "wordCount": "1637", + "wordCount": "1814", "datePublished": "2018-06-04T19:49:54-07:00", - "dateModified": "2018-06-14T12:40:42+03:00", + "dateModified": "2018-06-14T14:46:09+03:00", "author": { "@type": "Person", "name": "Alan Orth" @@ -427,6 +427,25 @@ UPDATE 1
  • I uploaded the seventy-six book chapters to the IWMI Book Chapters collection: https://cgspace.cgiar.org/handle/10568/36178
  • +

    2018-06-24

    + + + +
    $ dropdb -h localhost -U postgres dspacetest
    +$ createdb -h localhost -U postgres -O dspacetest --encoding=UNICODE dspacetest
    +$ psql -h localhost -U postgres dspacetest -c 'alter user dspacetest superuser;'
    +$ pg_restore -h localhost -U postgres -d dspacetest -O --role=dspacetest -W -h localhost /tmp/cgspace_2018-06-24.backup
    +$ psql -h localhost -U postgres dspacetest -c 'alter user dspacetest nosuperuser;'
    +
    + + + diff --git a/docs/robots.txt b/docs/robots.txt index f80484daa..12c3510ab 100644 --- a/docs/robots.txt +++ b/docs/robots.txt @@ -36,7 +36,7 @@ Disallow: /cgspace-notes/2015-12/ Disallow: /cgspace-notes/2015-11/ Disallow: /cgspace-notes/ Disallow: /cgspace-notes/categories/ -Disallow: /cgspace-notes/tags/notes/ Disallow: /cgspace-notes/categories/notes/ +Disallow: /cgspace-notes/tags/notes/ Disallow: /cgspace-notes/posts/ Disallow: /cgspace-notes/tags/ diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 795a236d4..77c91df87 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -4,7 +4,7 @@ https://alanorth.github.io/cgspace-notes/2018-06/ - 2018-06-14T12:40:42+03:00 + 2018-06-14T14:46:09+03:00 @@ -169,7 +169,7 @@ https://alanorth.github.io/cgspace-notes/ - 2018-06-14T12:40:42+03:00 + 2018-06-14T14:46:09+03:00 0 @@ -178,27 +178,27 @@ 0 - - https://alanorth.github.io/cgspace-notes/tags/notes/ - 2018-06-14T12:40:42+03:00 - 0 - - https://alanorth.github.io/cgspace-notes/categories/notes/ 2018-03-09T22:10:33+02:00 0 + + https://alanorth.github.io/cgspace-notes/tags/notes/ + 2018-06-14T14:46:09+03:00 + 0 + + https://alanorth.github.io/cgspace-notes/posts/ - 2018-06-14T12:40:42+03:00 + 2018-06-14T14:46:09+03:00 0 https://alanorth.github.io/cgspace-notes/tags/ - 2018-06-14T12:40:42+03:00 + 2018-06-14T14:46:09+03:00 0