How can I do this in one step?
Download backup command:
curl Restore backup command:
sudo -u postgres psql <PIPE-THE-OUTPUT-OF-PREVIOUS-COMMAND> 3 Answers
If both command are working, you should try
curl -s | sudo -u postgres psql I know this is an old question, but I just stumbled upon during a search (it was the top of the results) and it does not look like any of the answers are correct according to the postgres manual.
The manual suggests passing the -f - as an option to psql and then piping over stdin what ever you want. Quoting the manual for 9.4:
If filename is - (hyphen), then standard input is read until an EOF indication or \q meta-command. Note however that Readline is not used in this case (much as if -n had been specified).
Using this option is subtly different from writing psql < filename. In general, both will do what you expect, but using -f enables some nice features such as error messages with line numbers.
Yet another way:
sudo -u postgres psql --file <(curl -s )