Yedeği alıncak server tarafında,
sudo su – postgres pg_dump vt_adi > vt_adi_db.bak şeklinde yedek alındıktan
sonra pwd ile dizin kontrolü yapıp winSCP tarzı bir programla .bak uzantılı dosya kişisel bilgisayara alınabilir.
Aktarılacak server tarafında,
WinSCP ile kişisel pcye alınan yedek kopyalanır sonrasnda, psql empty_database < vt_adi_db.bak ile veriler aktarılmış olur. webten kontrol etmek için phppgadmin kurulur. sudo apt install phppgadmin ipadresi/phppgadmin ile webten girilir.
Problem:
Forbidden You don’t have permission to access /phppgadmin/ on this server. hatası alırsanızda.
Solution: sudo vi /etc/apache2/conf-enabled/phppgadmin.conf remove “Require local”, and restart apache2
Bu işlem bu kadar.
CONNECT TO THE REMOTE SERVER
First things first, you need to login to the remote server:
1
|
root@netdisco:~$ ssh root@remote–host
|
CHANGE THE LISTEN ADDRESS
By default, PostgreSQL DB server listen address is set to the ‘localhost’ , and we need to change it so it accepts connection from any IP address; or you can use comma separated list of addresses. Here is how it looks by default:
1
2
|
root@netdisco:/# grep listen /etc/postgresql/10/main/postgresql.conf
listen_addresses = ‘localhost’ # what IP address(es) to listen on;
|
Open your postgresql.conf file in your editor:
1
|
root@netdisco:/# vim /etc/postgresql/10/main/postgresql.conf
|
search for listen_addresses , and set it to ‘*’ :
1
2
3
4
5
6
7
|
#——————————————————————————
# CONNECTIONS AND AUTHENTICATION
#——————————————————————————
# – Connection Settings –
listen_addresses = ‘*’ # what IP address(es) to listen on;
|
or if you want to set connection restrictions to a few IP’s, then you should setlisten_addresses to something like this:
1
2
3
4
5
6
7
|
#——————————————————————————
# CONNECTIONS AND AUTHENTICATION
#——————————————————————————
# – Connection Settings –
listen_addresses = ‘192.168.1.100,192.168.1.101,192.168.1.110’ # what IP address(es) to listen on;
|
OPEN POSTGRESQL TO THE WORLD
In this step, you need to allow remote connections to actually reach your PostgreSQL server. Open pg_hba.conf :
1
|
root@netdisco:/# vim /etc/postgresql/10/main/pg_hba.conf
|
To allow connections from absolutely any address with password authentication add this line at the end of pg_hba.conf file:
1
|
host all all 0.0.0.0/0 md5
|
You can also use your network/mask instead just 0.0.0.0/0 .
RESTART
You have made it! Just make sure to restart your PostgreSQL instance before leaving remote SSH session:
1
|
root@netdisco:/# /etc/init.d/postgresql restart
|
Now you should be able to connect to the PostgreSQL instance with any of DB tools.
Yorumu formunu geç ↓
kazim uslu
8 Nisan 2019, 22:42 (UTC 3) Bu yoruma bağlantı
hocam kodlar centos için galiba, ubuntu için olanları verebilir misin ?
Metin Karaca
19 Mayıs 2019, 03:04 (UTC 3) Bu yoruma bağlantı
Merhaba Hüseyin Parmaksız hocam sayenizde sorunsuz yedek aldım teşekkür etmek istedim.
Hüseyin
29 Ağustos 2019, 04:18 (UTC 3) Bu yoruma bağlantı
Çok yardımcı oldu teşekkür ederim hocam
Tarık Öztürk
9 Ekim 2019, 19:05 (UTC 3) Bu yoruma bağlantı
tam aradığım birşeydi faydalı oldu teşekkür ederim.