Questions tagged [bash]

28 questions
7
votes
1 answer

How to pass environment variables to a sql file from bash shell (PostgreSQL)

I need to be able to pass environment variables, from a bash shell executing a .sql file using psql. The psql command I am running is: su postgres -c "psql -v ON_ERROR_STOP=1 -v dbname=example -v dbuser=example -e" < ./create-db.sql Where I have…
Adam Birds
  • 173
  • 1
  • 4
6
votes
5 answers

What does "psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (required by psql)" actually mean?

I have a question regarding following output: [nikola@192 ~] $ sudo su - postgres [postgres@192 ~] $ psql dvdrental postgres psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (required by psql) psql: /usr/pgsql-11/lib/libpq.so.5:…
NikolaS
  • 272
  • 1
  • 3
  • 12
3
votes
1 answer

execute mysqlshell from within a bash script? is it possible?

I am writing a backup script for a database and want to use mysqlshell util.dumpSchemas() utility. But how on earth can I make it work from within a shell script? The basic process I have is this: filename_1: backup.sh . . . mysqlsh --file…
IGGt
  • 2,266
  • 6
  • 35
  • 49
2
votes
1 answer

Run PSQL command from bash script

I would like to know how to run \du within a script, and output that to a file. Something like the following: # some_script.sh psql & \du > output_of_du.txt I can find information about running .sql files via psql, but I…
baxx
  • 326
  • 2
  • 7
  • 18
2
votes
2 answers

pg_dump hangs in Git Bash but works in Windows command line

I tried to make a backup of a database from Git Bash environment, but the executable does not output anything. If I specify the filename using the -f flag, a blank file gets created, so the executable obviously runs, but it does not do anything -…
JohnEye
  • 173
  • 9
2
votes
1 answer

Why does Postgresql Data directory revert to default after updates/reboots?

I have something that is pretty simple to explain. We have certain server builds as it relates to directories in our CentOS boxes at my company and so to accommodate those, I have a script that changes the PostgreSQL data directory. However, there…
Chris Jones
2
votes
2 answers

Could not find a "psql" to execute

I have a bash script that run on a Linux (AWS Centos) server. There's an odd, but annoying warning message that pops up in the stdout whenever the script executes psql: could not find a "psql" to execute. What is odd is that that the Postgresql…
apt605
  • 83
  • 1
  • 1
  • 5
1
vote
1 answer

Take a backup from specific range

I need to backup the data of a specific table by week and then restore it but without truncate table . This table contains the fechaRegistro I prepared the following script but I'm not sure about the way to declare date variables, could you help me…
Carolina
  • 47
  • 5
1
vote
0 answers

Taking full and incremental backups with authentication in MongoDB

We have a multi-tenant micro-service (it's basically kafka with some bells and whistles). We are using Mongodb to store multi-tenant credentials and kafka data so the authentication is really tight. Like, tenant1 will get to read/write tenant1-db…
DarkDead
  • 11
  • 1
1
vote
1 answer

Postgres how do return a message if no results for SELECT query

Have been trying to work out how to return a message if the result is empty. I am running a select statement as below: select * from maxIDValue where max_value > 1000000 order by max_value desc; I am running this in a bash script via psql however…
rdbmsNoob
  • 459
  • 9
  • 30
1
vote
1 answer

How to return values from psql to bash with custom session settings

I need to set the datestyle to "dd/mm/yyyy" before calling a procedure and getting it's return value back to bash. I tried the following: read return <<< $(psql \ -x \ -U postgres \ -d MY_DB \ …
Majd
  • 121
  • 3
1
vote
1 answer

Save output of a Mongo Command to a Variable bash script

I have been writing a script to find and kill slow mongodb queries, how can I store output of db.currentOp() in a variable? current I am using this but failing #! /bin/bash out="" mongo <<…
DB guy
  • 69
  • 3
  • 8
1
vote
0 answers

How to simulate slow queries on MongoDB

I need to write a shell script that finds and kills long running mongodb queries, but I don't have access to the database that runs slow queries, how to I simulate running slow queries on my local machine running mongodb v3.6.8, so that I get some…
DB guy
  • 69
  • 3
  • 8
0
votes
1 answer

capture deleted rows count in a variable from mysql table using bash script

I am trying to capture the number of deleted rows from mysql table from a bash script using --execute option, and it seems to be not working. I have gone through some questions where it mentions using -vv options, it works but not as expected. I…
Avinash Pawar
  • 216
  • 2
  • 11
0
votes
1 answer

How do I ensure that MySQL is writing out its error log as the correct user?

I have a development Airflow server. It uses MySQL as its database. In the mysqld settings, I have the user set to mysql. However, the log is being written out as a different user named adm whenever the log is rolled over. I have confirmed I have…
Zack
  • 121
  • 2
1
2