dizda / CloudBackupBundle

Be able to backup your database(s) and upload it to the cloud (Dropbox, Amazon S3, GoogleDrive, etc.)
MIT License
196 stars 57 forks source link

Problem with backup DB. #78

Closed tim96 closed 8 years ago

tim96 commented 8 years ago

@dizda hello. I try to create backup of my MySQL database, but I have some problem, when I run command:

php app/console --env=prod dizda:backup:start

show error:

php app/console --env=prod dizda:backup:start
[2015-10-18 11:56:22] app.CRITICAL: [dizda-backup] Unexpected exception. {"exception":"[object] (RuntimeException(code: 0): Unknown suffix ''' used for variable 'port' (value ''3306'')\r\nmysqldump: Error while setting value ''3306'' to 'port'\r\n at vendor\\dizda\\cloud-backup-bundle\\Dizda\\CloudBackupBundle\\Database\\BaseDatabase.php:45)"}
Something went terribly wrong. We could not create a backup. Read your log files to see what caused this error.

It seems what problem in suffix '''. How I can fix it?

dizda commented 8 years ago

Can you try to remove the quotes in your mysql db_port ?

tim96 commented 8 years ago

I create var_dump of backup command:

string(180) "mysqldump --host='127.0.0.1' --port='3306' --user='tim' --password='' db1 > G:\db1\app\cache\prod/backup/mysql/db1.sql"

Can you try to remove the quotes in your mysql db_port ?

@dizda, I try this in my parameters.yml, but I still have this error:

database_port: null

I found what this suffix appear in this line:

$this->auth = sprintf("--host='%s' --port='%d' --user='%s' --password='%s'"
dizda commented 8 years ago

You should leave the port, did you try like this?

database_port: 3306
dizda commented 8 years ago

Weird, the command looks correct

tim96 commented 8 years ago

You should leave the port, did you try like this?

@dizda Yes, I try it. The same error.

I change this line with suffix:

$this->auth = sprintf("--host='%s' --port='%d' --user='%s' --password='%s'"

to this in MySQL.php file:

$this->auth = sprintf("--host=\"%s\" --port=\"%d\" --user=\"%s\" --password=\"%s\"",

And it seems to work for me.

dizda commented 8 years ago

Hmm weird, I think it's because mysqldump's behavior is different on Windows.

Well, can you send a PR to fix this bug? Thanks

tim96 commented 8 years ago

Well, can you send a PR to fix this bug? Thanks

Ok, I try to do it. Thanks

tim96 commented 8 years ago

Fixed