Skip to content

Instantly share code, notes, and snippets.

@dlangille
Created January 8, 2019 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/c548cf845b36a6226480022a09098b73 to your computer and use it in GitHub Desktop.
Save dlangille/c548cf845b36a6226480022a09098b73 to your computer and use it in GitHub Desktop.
permissions for database backup
#!/bin/sh
# these permissions only need to be run once, and then it allows rsyncer to backup the databases
SCHEMAS="auth base conflict custom log momomoto public release"
DATABASES="pentabarf_bsdcan pentabarf_pgcon"
for schema in ${SCHEMAS}
do
for database in ${DATABASES}
do
echo echo \""grant usage on schema ${schema} to rsyncer;\"" \| psql ${database}
echo "grant usage on schema ${schema} to rsyncer;" |psql ${database}
echo echo \""grant select on all tables in schema ${schema} to rsyncer;\"" \| psql ${database}
echo "grant select on all tables in schema ${schema} to rsyncer;" | psql ${database}
echo echo \""grant select on all sequences in schema ${schema} to rsyncer;\"" \| psql ${database}
echo "grant select on all sequences in schema ${schema} to rsyncer;" | psql ${database}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment