1

I would like to dump postgres database and make it periodical with crontab.

so I tried to run the following in a bash script:

sudo -u postgres pg_dump --dbname=postgresql://django:mypass@127.0.0.1:5432/django

I get this:

-bash: !: event not found

probably because there are special characters in the password. how to escape from special characters? how can I pass the password parameter? is there any other way to auto dump periodically from postgresql.

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
schism11
  • 11
  • 1

1 Answers1

0

You must encode the special characters.

If your password is a!b@c , the command would be

sudo -u postgres pg_dump --dbname=postgresql://django:a%21b%40c@127.0.0.1:5432/django
JGH
  • 13,365
  • 4
  • 28
  • 43