Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. /*
  2.  
  3. Description
  4. -----------
  5.  
  6. This script creates a read-only Postgres user with access
  7. to the Qlik Sense QSR and QLogs databases. You can use this
  8. user to perform backups of your Qlik Sense Repository and
  9. Centralized Logging databases.
  10.  
  11. Configuration
  12. -------------
  13.  
  14. On the lines below containing the \set statements, change
  15. the username and password to your desired values. Default
  16. below is set to username 'qliksensebackup' and password
  17. 'yourpassword'
  18.  
  19. Executing the script
  20. --------------------
  21.  
  22. To run this script, you need the password for the
  23. Qlik Sense Repository Superuser.
  24.  
  25. On your central node, open a command line or PowerShell window
  26. in the Postgres folder supplied with Qlik Sense. As of February 2019,
  27. this is the default location:
  28.  
  29. 'C:\Program Files\Qlik\Sense\Repository\PostgreSQL\9.6\bin'
  30.  
  31. In this folder, execute the following command:
  32.  
  33. 'psql -p 4432 -U postgres -f path\to\create_sense_backup_user.sql'
  34.  
  35. */
  36.  
  37.  
  38.  
  39. \set username qliksensebackup
  40. \set password yourpassword
  41.  
  42.  
  43. -- Note: if the backup user already exists then comment the line below with -- (double hyphen)
  44. CREATE USER :username WITH ENCRYPTED PASSWORD :'password';
  45.  
  46.  
  47.  
  48. \echo Setting permissions for :username
  49. \echo ********************************************
  50.  
  51. GRANT CONNECT ON DATABASE postgres TO :username ;
  52. GRANT CONNECT ON DATABASE "QSR" TO :username ;
  53. GRANT CONNECT ON DATABASE "QLogs" TO :username ;
  54.  
  55.  
  56. \ echo Setting permissions on 'postgres'
  57. \c postgres
  58. GRANT USAGE ON SCHEMA public TO :username ;
  59. GRANT SELECT ON ALL TABLES IN SCHEMA public TO :username ;
  60. ALTER DEFAULT PRIVILEGES IN SCHEMA public
  61. GRANT SELECT ON TABLES TO :username ;
  62. GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO :username;
  63. ALTER DEFAULT PRIVILEGES IN SCHEMA public
  64. GRANT SELECT ON SEQUENCES TO qliksensebackup;
  65.  
  66.  
  67. \ echo Setting permissions on 'QSR'
  68. \c "QSR"
  69. GRANT USAGE ON SCHEMA public TO :username ;
  70. GRANT SELECT ON ALL TABLES IN SCHEMA public TO :username ;
  71. ALTER DEFAULT PRIVILEGES IN SCHEMA public
  72. GRANT SELECT ON TABLES TO :username ;
  73. GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO :username;
  74. ALTER DEFAULT PRIVILEGES IN SCHEMA public
  75. GRANT SELECT ON SEQUENCES TO qliksensebackup;
  76.  
  77.  
  78. \ echo Setting permissions on 'QLogs'
  79. \c "QLogs"
  80. GRANT USAGE ON SCHEMA public TO :username ;
  81. GRANT SELECT ON ALL TABLES IN SCHEMA public TO :username ;
  82. ALTER DEFAULT PRIVILEGES IN SCHEMA public
  83. GRANT SELECT ON TABLES TO :username ;
  84. GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO :username;
  85. ALTER DEFAULT PRIVILEGES IN SCHEMA public
  86. GRANT SELECT ON SEQUENCES TO qliksensebackup;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement