1

Iam newbie in linux, and i've looking for this solution but i still cannot doing it. I want to backup my database automatically every week by entering the command into the cronjob. But when the command is executed automatically, it will ask for username and password and it becomes not automatic coz user should entering it manually. How do I input the username and password automatically?

The prompt is: GSQL username: then GSQL password:

Thank you

  • MySQL and PostgreSQL allows to set username / password inside environment variables. So, if you set `export MYSQL_PWD='some!password?'` for example, you will be able to run `mysql --user username` without any prompts. Your question should be like: `How to create dump of XXX database without password prompt` (where XXX is a database type) – rzlvmp Jan 25 '23 at 04:32
  • Ah I got your point, the prompt also said `environment variable GSQL_USERNAME not set, gsql username is required ...` and `environment variable GSQL_PASSWORD not set, gsql password is required ...` so its mean i need to export GSQL_USERNAME and GSQL_PASSWORD to the env path, right? I just not sure what should i do, so iam asking to stackoverflow – Yudha Restu Jan 25 '23 at 04:40
  • please provide code of cron command – rzlvmp Jan 25 '23 at 04:41
  • the cron command is only `gbar backup` then the prompt asking for username and password like i told in question – Yudha Restu Jan 25 '23 at 04:42

1 Answers1

0

Cron command should be like:

GSQL_USERNAME='actualUsername' GSQL_PASSWORD='actualP@ssw0rd' gbar backup

or

export GSQL_USERNAME='actualUsername' && export GSQL_PASSWORD='actualP@ssw0rd' && gbar backup

These command lines set Environment variables first and then runs backup command.

Details here:

You can specify the number of parallel processes for backup and restore.

You must provide the username and password using GSQL_USERNAME and GSQL_PASSWORD environment variables.

GSQL_USERNAME=tigergraph GSQL_PASSWORD=tigergraph gbar backup -t daily

rzlvmp
  • 7,512
  • 5
  • 16
  • 45