recover backup of firebird fail - backup

I previously asked how to make a backup of a Firebird database in
I need to backup or clone one remote firebird database or export it to Sql server
Now the backup is complete, but when I try to restore it to Firebird on my computer, I get an error.
I use this command:
gbak -r -p 4096 -o e:\mybackup.fbk localhost:e:\bddados.fdb -user sysdba -pas masterkey
The error I receive is
gbak: ERROR:Your user name and password are not defined. Ask your database administrator to set up a Firebird login. gbak:Exiting before completion due to errors
But I test my Firebird locally with this user and password and it's ok. Does the created backup database need to specify in generate command a password or do I need to use the same of the old database?

user and pas[sword] parameters should be before the path to files
gbak -r -p 4096 -o -user sysdba -pas masterkey e:\mybackup.fbk localhost:e:\bddados.fdb
gbak documentation

Related

Root with no permission to work with psql

I need to use root user to run scripts at crontab, for example to read and write on all /home folders.
But something that I need to do also in the shell script is to run psql. Problem:
my user (me = whoami and not is root) can run for example psql -c "\l"
the root user not works (!) with psql -c "\l"... And error not make sense "psql: error: could not connect to server: FATAL: database "root" does not exist".
How to enable root to run psql?
PS: looking for a kind of "GRANT ALL PRIVILEGES ON ALL DATABASES TO root".
root is allowed to run psql, but nobody can connect to a database that doesn't exist.
The default value for the database user name with psql is the operating system user name, and the default for the database is the same as the database user name.
So you have to specify the correct database and database user explicitly:
psql -U postgres -d postgres -l
The next thing you are going to complain about is that peer authentication was denied.
To avoid that, either run as operating system user postgres or change the rules in pg_hba.conf.

How do you add a pre-existing database to Postgres?

I am using Postgres in my production server that houses my Django application. I am trying to create a database in psql that already exists. I have the host name, username, password, port, all that good stuff, but after reading Postgres' documentation it seems that there is no way to add in a prexisting database.
No, you cannot create a database if it's already created.
It seems like you have a dump (a .sql file) that you want to load in your production server.
By default pg_dump will not include the CREATE DATABASE statement into the .sql file so you should be able to load the .sql file just doing:
psql -h <DB_HOST> -U <DB_USER> -p <DB_PORT> -W <DB_NAME> < <PATH_TO_YOUR_SQL_FILE>
Example:
psql -h localhost -U db_user -p 5432 -W db_name < /tmp/my_dump.sql
That's it.
Let me know if you have any issues doing that.
Cheers

How to dump a Postgres database if the user has no password set?

I dont have a lot of experience with Postgres, so I'm having a bit of a trouble accessing a database I just rescued from a broken Ubuntu server.
What I'm trying to do: The server that was sporting postgres is dead now, I can only access it via "rescue mod" provided by the hosting company. I tried chroot in order to dump the database using pg_dump or pg_dumpall, but it seems that the server is unreachable in this way. The dump attempts to enroute himself via rescue.ovh.net (OVH being the hosting provider), even if I specify -h localhost.
So I came with a different idea: copying the whole Postgres folder into a local machine, and then dumping the database and keep on restoring everything starting from this dump. This is something you can do in MySQL, so I thought that this maybe would be possible with Postgres.
But so far it is not workin. I copied /var/lib/postgres folder to my local machine (taking care that the owner in my local machine is also the postgres user), but when I try to dump a database, I can't really do it.
The errors vary on the command:
My first attempt is to dump the database using the database user:
$ pg_dump -U discourse -h localhost > discourse_prod.sql
Password:
pg_dump: [archiver (db)] connection to database "discourse" failed: fe_sendauth: no password supplied
The prompt asks for a password, the user did not have a password, but If i just press enter it aches and says no password provided.
My second attempt was dumping via postgres admin user:
sudo pg_dump -U postgres discourse_prod > ~/test.sql
I get a pg_dump: [archiver (db)] connection to database "discourse_prod" failed: FATAL: Peer authentication failed for user "postgres". So I try to switch user before trying to dump...
sudo -u postgres pg_dump -Fp discourse_prod > dump.sql
and now it seems that the database was not properly copied: pg_dump: [archiver (db)] connection to database "discourse_prod" failed: FATAL: database "discourse_prod" does not exist
As I said, I have not very much experience with Postgres, and I'm running out of ideas... on how to get a dump out from these files, i don't mind if I manage to get it from the devastated machine or from my locally copied files.
Any ideas?

mysqldump ask for password even thou given on commandline/config-file

I am in the process of migrating my MySQL installation to Amazon RDS and they run MySQL Server version 5.6.12.
I got the client tools of version 5.6.13 and trying to use mysqldump for automated backups.
I always get the question to enter password which block my scripting of backups.
I looks like this:
ubuntu#ip-10-48-203-112:~$ mysqldump --user=dbadmin -pmysecretpassword -h someserver.eu-west-1.rds.amazonaws.com -p skygd > dump.sql
Warning: Using a password on the command line interface can be insecure.
Enter password:
I have tried with a configuration file .my.cnf
[client]
user=dbadmin
password=mysecretpassword
And it is picked up ok, if I run:
mysqldump would have been started with the following arguments: --port=3306 --socket=/var/run/mysqld/mysqld.sock --quick --quote-names --max_allowed_packet=16M --user=dbadmin --password=mysecretpassword
But still same question about enter password.
Are there a bug in 5.6.13 that doesn't allow automated login with password?
mysqldump --user=dbadmin --password=mysecretpassword -h someserver.eu-west-1.rds.amazonaws.com skygd > dump.sql
you typed -p at the end of the line
It is a better option to mention mysql password at the end of the first command.
mysqldump -uUsername -p"space-here"Databasename -h"space-here" Hostname >xyz.sql
And for database import use
mysql -uUsername -p"space-here"Databasename -h"space-here"Hostname

PostgreSQL - Create user and database from shell failing

I have a shell script which runs on deployment and I have these lines:
# Database
createdb $DBNAME
createuser -D -A $DBNAME
However, in my logs I get this error:
createdb: could not connect to database postgres: FATAL: Ident
authentication failed for user "root"
createuser: could not connect to database postgres: FATAL: Ident authentication failed for
user "root"
Would anyone mind telling me what is going wrong here and how I can correct my lines. Surely root should have permission to do this?
the best way to do this, especially if you want your script to be portable, is:
su --login postgres --command "createdb $DBNAME"
this should be safer, more secure, and more portable than using -U. i do it this way in all my posgreSQL scripts. you might find it a useful technique. obviously it still needs to be run as a root user (e.g. with sudo).
If your DB is secured, you need to connect as a DB user, not as a user of the OS. For example:
createdb -U dbrootuser -W $DBNAME
See this link for full syntax