Category Archives: PostgreSQL

Barman

# install barman
apt-get install barman

# generate ssh keys for user barman
sudo -u barman -i
ssh-keygen
cd ~/.ssh/
cp id_rsa.pub authorized_keys
# cat id_rsa.pub and copy it
exit

# generate ssh keys for user postgres
sudo -u postgres -i
ssh-keygen
cd ~/.ssh/
cp id_rsa.pub authorized_keys
# put barman's id_rsa.pub into postgres's authorized_keys
# cat postgres'sid_rsa.pub and copy it
exit

sudo -u barman -i
# put id_rsa.pub postgres's id_rsa.pub into barman's authorized_keys
exit

add config of your postgresql server into /etc/barman.conf:

1
2
3
4
[srv1]
description = "srv1 pgsql"
ssh_command = ssh postgres@127.0.0.1
conninfo = host=127.0.0.1 user=postgres

where srv1 — name of server

barman check
barman status srv1
barman backup srv1
barman cron
man barman

Postgresql: export/import users with privileges

It's easy to transfer users from one instance to anothe:
#dump users and permissions
sudo -u postgres pg_dumpall -g > globals_only.dump
#restore them
cat globals_only.dump | sudo -u postgres psql
# or if you would like to choose specific user
grep USERNAME globals_only.dump

1
2
3
CREATE ROLE "USERNAME";
ALTER ROLE "USERNAME" WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION PASSWORD 'md56933b22c7ea06924799dbac5d7ed8072';
GRANT ro TO "USERNAME" GRANTED BY postgres;

These commands you could input directly to postgres command-line.

IT Security Brothers (http://itsb.pro)

Hi guys, I would like to present you our new project IT Security Brothers http://itsb.pro
We provide pentest, consultations and IT outsourcing services.
Feel free to hire us for IT jobs.

Postgresql 9.2 for Ubuntu 12.04 and 10.04

Add repository: http://www.postgresql.org/download/linux/ubuntu/

1
2
3
echo deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main | sudo tee /etc/apt/sources.list.d/postgresql.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

setup postgres:

1
sudo apt-get install postgresql-9.2 postgresql-contrib-9.2