I'm logged into remote using ssh
ubuntu@ubuntu:~$
now I switch to postgres account using sudo su - postgres command and it send me to postgres@ubuntu:~$
now here I'm able to take dump using pg_dump command.
e.g. postgres@ubuntu:~$ pg_dump db_name > mydbdump.sql
so far looks good. but from here I want to copy this dump file to my local machine or even to my origin/default ubuntu user on remote(ubuntu@ubuntu:~$). so that from there I can scp.
how do I copy these dump sql files from postgres acccount to ubuntu on remote?
pwdto determine current directory. It will return something like/var/lib/postgresql. Then return back to yourubuntuuser:exit. And copy dump to your user's home directory:cp /var/lib/postgresql/mydbdump.sql ~/mydbdump.sql. After that you'll be able to copy it to your local machine usingscppwd). Then you just copy it with your normal ubuntu user to your home and use scp:sudo cp /path/to/mydbdump.sql /home/ubuntu/. Now you can use scp:scp [email protected]:/home/ubuntu/mydbdump.sql .and you are done. Futhermore this question rather belongs to serverfault.com or superuser.com