Step-1 login to the server by using ssh kya and ip
Ex- ssh ‘user@101.111.00.01′
then provide password
step-2 login to the post by using
sudo su – postgres
Provide password for postgres
pg_dump slips99 > xyz.sql (make sure we are oing to have proper dump from server – production/development mode)
you will get db dump, can check by ls
step -3 exit from postgres by exit
you will go to root dir
step-4 go to postgres dir by using
cd var/lib/postgres
step-5 copy yout backup by in your project public folder by using
cp xyz.sql ~/My_app/public
step-6 now download xyz from browere as
myapp.com/xyz.sql
now u have DB back on local
step-7 copy and paste xyz.sql from download to local postgres dir
you may need to use sudo nautilus to copy and pase
step-8 make sure you db must be empty to insert new dump fro this we can use
rake db:drop (to empty db)
step-9 Restore: – login to local postgres on local by sudo su – postgres and password then
psql new_db < xyz.sql
(sudo nano /etc/postgresql/9.4/main/pg_hba.conf) if postgres not allow to login the use this command and uncomment last three lines as
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
step-10 we may need permission for this new file, we can do this by
laptop@laptop:/var/lib/postgresql$ sudo chmod 777 -R xtz.sql
[sudo] password for laptop:
laotop@laptop:/var/lib/postgresql$
step- 11 if we get some error then check weather database exit or not id=f not then create db by
rake db:create
step -12 then
psql new_db < xyz.sql