SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid();
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# PostgreSQL Backup Script Ver 1.0 | |
# http://autopgsqlbackup.frozenpc.net | |
# Copyright (c) 2005 Aaron Axelsen <[email protected]> | |
# | |
# This script is based of the AutoMySQLBackup Script Ver 2.2 | |
# It can be found at http://sourceforge.net/projects/automysqlbackup/ | |
# | |
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Steps to upgrade/install and run PostgreSQL 9.4.3 using Homebrew (Mac OS X) | |
(if you aren't using version 9.3.5_1, change line 6 with the correct version) | |
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
2. mv /usr/local/var/postgres /usr/local/var/postgres-9.3 | |
3. brew update | |
4. brew upgrade postgresql | |
5. initdb /usr/local/var/postgres -E utf8 | |
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.3.5_1/bin -B /usr/local/Cellar/postgresql/9.4.3/bin -d /usr/local/var/postgres-9.3 -D /usr/local/var/postgres |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE ROLE queryUser WITH NOCREATEDB NOCREATEROLE NOCREATEUSER NOINHERIT NOREPLICATION ENCRYPTED PASSWORD '****' CONNECTION LIMIT 1 LOGIN; | |
GRANT USAGE ON SCHEMA public TO queryUser; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO queryUser; |
pg_ctl -D /usr/local/var/postgres stop -s -m fast
pg_ctl -D /usr/local/var/postgres/ -l /usr/local/var/postgres/server.log start
for tbl in psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" -h localhost -U postgres -d DATABASE
; do psql -c "alter table "$tbl" owner to ROLE" -h localhost -U postgres -d DATABASE ; done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# install mdbtools first! | |
# mdbtools: https://github.com/brianb/mdbtools | |
# ref: https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL | |
DBMS=postgres | |
for MDB in `ls | grep .mdb$` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to migrate postgis | |
# Backup database | |
pg_dump -h localhost -p 5432 -U postgres -Fc -b -v -f "olddb.backup" db-name | |
# Create database | |
psql -c -U postgres "CREATE DATABASE db-name;" | |
# Apply postgis complements to the new database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#title :wildfly-install.sh | |
#description :The script to install Wildfly 10.x | |
#more :http://sukharevd.net/wildfly-8-installation.html | |
#author :Dmitriy Sukharev | |
#date :2015-10-24T17:14-0700 | |
#usage :/bin/bash wildfly-install.sh | |
#tested-version :10.0.0.Final | |
#tested-distros :Debian 7,8; Ubuntu 15.10; CentOS 7; Fedora 22 |
OlderNewer