I need to backup postegresql database of rails project deployed on EC2 using Capistrano. So how can i do that and also i want to save backup data on my local computer
Easy way to find where you PG data located: run:
ps aux | grep postgres | grep -- -D
or
ps ax | grep postgres | grep -v postgres
than zip this folder(for example /var/postgres/9.5/data i have no idea where is on your server) run:
sudo zip -r ~/9_5_postgres.zip /var/postgres/9.5/data
download it on local machine
scp server-user-name@ip-address:~/9_5_postgres.zip ~/
unzip it
unzip ~/9_5_postgres.zip
probably folder unzipped in ~/var/postgres/9.5/data user folder and then run postgres server(stop postgres before and use stop/start/restart in the end):
pg_ctl -D ~/var/postgres/9.5/data -l ~/var/postgres/9.5/pg.log start
Use in your config/database.yml same password login as in production and chine on prod if you commit you config/database.yml in git
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.