DB backup tool, parameters
- pistols
- Member | 26
Hi there, please advice, I am currently preparing an on demand backup of the db my nette app works on. Unfortunetally my hosting doesn't allow any fancy tools so i will need to do it via php
I am thinking of using this: dg/MySQL-dump
The object needs a mysqli object to be constructed. I want to ask you, what is the best practice for converting a nette\database\connection to mysqli?
Should I really manually parse the dsn of the connection? and (stupid question follows) how do I retrieve the username and password from the nette\database\connection object?
Thanks in advance
- pistols
- Member | 26
Ok, I thought so. But what still bothers me (shame on me) is that I cannot extract the username, password and dns from the \Nette\Database\Connection object. I pass the database to my model, but the params of the connection are private. could you please advice how to? I am expecting something like $this->database->connection->params[0]. But thats not it.
Thanks a lot
- pistols
- Member | 26
Yes, thats the approach I understand :). But I have still some fundamental unknowledge :)
I dont want to define my DB parameters again, but use the ones I have already defined under
development:
nette:
database:
dsn: sdfsdfsdf
user: sdkl
pass: sdfsg
OR
production:
nette:
database:
dsn: hkhjhjk
user: hjk
pass: hjk
according to the current scope (on production use the production credentials etc..).
Just to clarify what i need and it doesnt work is this:
services:
- MySQLDump
- mysqli(
%nette.database.host%,
%nette.database.username%,
%nette.database.password%,
%nette.database.scheme%
)
Last edited by pistols (2014-09-19 10:01)
- petr.pavel
- Member | 535
I think @pistols missed that in @Casper's sample code,
the login credentials were stored in parameters/database
– not
in nette/database
as @pistols' later code shows.
- petr.pavel
- Member | 535
But @Casper already showed you. %database.host%
etc. What
did you not understand about it?
- pistols
- Member | 26
petr: I dont want to create a new section under parameters to keep my credentials. I have already defined them in config.local.neon
development:
nette:
database:
dsn: ...
and
production:
nette:
database:
dsn: ....
and thats the place from where I want to take them… (in other words I don't want to define the same information in two separate places)
Last edited by pistols (2014-09-19 10:48)