Where can I find Postgresql dump file? - database

I use this command to create dump file from Postgresql database
pg_dump rulings > rulings.sql
But I can not find any SQL dump file from
C:\Program Files\PostgreSQL\12\bin
Command-line does not say anything about it, therefore I can not see if there is any error.
How can I find it??

In this case the dump file is created in the current directory, ie. the directory where pg_dump has been started. if this is run a script, check the directory used in the script.

Related

How to rename a downloaded file from within the WinSCP script?

I have WinSCP script that downloads a file from the SFTP server to the local machine. How can I rename the file from within the WinSCP script?
The script is being run from Windows machine.
The WinSCP script:
option batch off
option confirm off
open sftp://username:password#servername -hostkey=""
option transfer binary
get -latest "oldname.csv" c:\localfolder
mv c:\localfolder\oldname.csv latestname.csv
exit
I tried renaming using the commands:
rename InitialFileName FinalFileName
then tried using:
mv InitialFileName FinalFileName
But the script is throwing the error:
File not found, Language: en
Tried stuff from this blog
If you want to download the file to a different name, specify the new name directly in the get command:
get "oldname.csv" c:\localfolder\latestname.csv
(Note that when downloading one specific file, the -latest switch is pointless. The latest file out of one file[s] is that one file.)

253006 (n/a): File doesn't exist:

I am trying to PUT a file into Snowflake staging area using PUT
command.
When I run the command using snowsql I am able to PUT the file in
stage area.
When I try to execute the same command from a shell script it is
throwing below error.
253006 (n/a): File doesn't exist: ['/home/raghu/sample_pipeline_config.csv']
Any help will be highly appreciated. FYI I am running the commands in
Ubuntu terminal.

SQL Server 2016 installation error

I am trying to install SQL Server 2016. I keep getting the following error:
The specified directory, "C:\Program Files (x86)\Microsoft SQL
Server\", for the INSTALLSHAREDWOWDIR parameter is not valid
because this directory is compressed or is in a compressed directory.
Specify a directory that is not compressed.
I have read posts online that suggest going to the program folder and uncompressing it. I have done this and it doesn't seem to work. I would really appreciate pointers on this.
Error message say :
this directory is compressed or is in a compressed directory. Specify a directory that is not compressed.
or in a compressed directory
There is one of this folders is compressed or both.
So follow this steps :
Check if YourDrive is compressed if it is then Uncompressing it.
Check if Program Files (x86) folder is compressed if it is then Uncompressing it.
Check if Microsoft SQL
Server folder is compressed if it is then Uncompressing it.
Try to install Microsoft SQL Server 2016.
If you got the same error then try to change the directory installation to any directory which is not compressed .
Error message says it all,you can't install SQL server in a directory which is compressed..
Try uncompressing it first or change the directory installation to any directory which is not compressed..
Uncheck below option and try installing..
Here is a KB which may help you

Mysqldump simple batch issue

I am trying to write a simple batch file to run a MySqlDump. I created a new file in notepad, pasted the text below, and then saved it as a bat file. However when I attempt to run this in command prompt the screen pops up right away and then goes away just as fast. If I run these commands manually in command prompt it works as expected.
This is my first bat file I have created so I'm guessing I am doing something wrong? In looking at similar issues in StackOverflow the code below appears to be what is suggested so I'm confused why this isn't working?
cd C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin
mysqldump --user=xxx --password=xxx --all-databases --single-transaction > C:\Users\JMaze\Desktop\nSite\MySQL Backup\bk.sql
Adding the quotes to each of the file paths appears to have fixed the issue. The final code looks like this:
cd "C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin"
mysqldump --user=xxx --password=xxx --all-databases --single-transaction > "C:\Users\JMaze\Desktop\nSite\MySQL Backup\bk.sql"

postgresql where does the output of pg_dump go

I am trying to backup a db of postgresql and I want to use pg_dump command.
I tried :
psql -U postgres
postgres-# pg_dump test > backup.sql
But I don't know where the output file goes.
Any help will be appreciated
I'm late to this party, but I feel that none of the answers are really correct. Most seem to imply that pg_dump writes a file somewhere. It doesn't. You are sending the output to a file, and you told the shell where to write that file.
In your example pg_dump test > backup.sql, which uses the plain or SQL format, the pg_dump command does not store any file anywhere. It just sends the output to STDOUT, which is usually your screen, and it's done.
But in your command, you also told your shell (Terminal, Command prompt, whatever) to redirect STDOUT to a file. This has nothing to do with pg_dump but is a standard feature of shells like Bash or cmd.exe.
You used > to redirect STDOUT to a file instead of the screen. And you gave the file name: "backup.sql". Since you didn't specify any path, the file will be in your current directory. This is probably your home directory, unless you have done a cd ... into some other directory.
In the particular case of pg_dump, you could also have used an alternative to the > /path/to/some_file shell redirection, by using the -f some_file option:
-f file --file=file
Send output to the specified file. This parameter can be omitted for file based output formats,
in which case the standard output is used.
So your command could have been pg_dump test -f backup.sql, asking pg_dump to write directly to that file.
But in any case, you give the file name, and if you don't specify a path, the file is created in your current directory. If your prompt doesn't already display your current directory, you can have it shown with the pwd command on Unix, and cd in Windows.
Go to command prompt and directory postgresql\9.3\bin.
Example
.
..
c:\Program files\postgresql\9.3\bin> pg_dump -h localhost -p 5432 -U postgres test > D:\backup.sql
...
After above command enter User "postgres" password and check D:\ drive for backup.sql file
In my situation (PostgreSQL 9.1.21, Centos 6.7), the command
runuser -l postgres -c 'pg_dump my_database > my_database.sql'
saved the file here:
/var/lib/pgsql/my_database.sql
Not sure if that is true for other Linux dists, CentOS and/or pgl versions. According to the answer post by the asker of this question, this is true, but other users said the backup file was in the current directory (a situation different of most people reading this thread, for obvious reasons). Well, I hope this can help other users with the same problem.
P.s.: if that's not the path for your situation, you can try (in Linux) to find it using the below command (as stated by #Bohemian in the comments of this question), but this can take a while:
find / -name 'my_database.sql'
EDIT: I tried to run the analogous command in Ubuntu 12.04 (it works on Ubuntu 18.04):
sudo -u postgres pg_dump my_database > my_database.sql
And in this case the file was saved in the current directory where I ran the command! So both cases can happen in Linux, depending of the specific dist you are working
For Linux default dump path is:
/var/lib/postgresql/
If you are not specifying fully qualified paths, like:
pg_dump your_db_name > dbdump
then in Windows it stores dumps in current user's home directory. I.e.:
C:\Users\username
If you use linux (except centos)
sudo su - postgres
pg_dump your_db_name > your_db_name.sql
cd /var/lib/postgresql
ls -l
Here your'll see your_db_name.sql file
In pgadmin 4 for a Mac, assuming dump is successful you can click on "More Details" you will see a box that says "Running command:" in that box you will see /Applications/pgAdmin 4.app/Contents/SharedSupport/pg_dump --file "path/to/file" where path to file is the destination of storage.
After doing
psql -U postgres
Using the command
\! pg_dump -U postgres humaine > C:\Users\saivi\OneDrive\Desktop\humaine_backup1.sql
The output file would go where the path at the right is specified
In the server (Ubundu/Centos) the path of backup file will be
/var/lib/pgadmin/storage/
Below is the OS specification.
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
I am using following command to take the backup of postgresql database.
pg_dump -U postgres -Fc <db_name> > /var/lib/postgresql/backup-20230123.dump
If storage file path has been provided explicitly, in that case, the database dump will be generated to that place only.
For windows, provide folder path where you want to download the dump.

Resources