Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In version 2: Could not create backup of db L5.0 #37

Closed
nam-co opened this issue May 19, 2015 · 48 comments
Closed

In version 2: Could not create backup of db L5.0 #37

nam-co opened this issue May 19, 2015 · 48 comments

Comments

@nam-co
Copy link

nam-co commented May 19, 2015

Hi freekmurze, sorry to bother you but Im getting this same errors in the local and digital ocean servers with the S3 and local settings, can you please tell me what can be wrong? mysqldump is install

appreciate any help, thanks and cool package can it be automatic with the new options in L5.1?

  1. php artisan backup:run
    Start backing up
    Determining which files should be backed up...
    [ErrorException]
    Invalid argument supplied for foreach()
  2. php artisan backup:run --only-db
    Start backing up
    [Exception]
    Could not create backup of db
@freekmurze
Copy link
Member

Things you can check:

  • does the destination directory exists? Is it writable. When backing up to S3, is the path in the bucket writable?
  • are the files specified in source.files.include and source.files.exclude correct?

If you can't find any issues, run the command with the -vvv flag to get more detail on the exception.

Though I haven't tested it out the package should work perfectly with L5.1 As soon as that version is available, I'll check it to make sure.

@mfsi-praveenm
Copy link

can you cite an example for paths because i am getting the same issue.

@freekmurze
Copy link
Member

There are paths configured in the config file by default

@mfsi-praveenm
Copy link

i have tried in my local machine with path mentioned,I am not sure where the 'backups' folder should reside.

@nam-co
Copy link
Author

nam-co commented May 26, 2015

Hi Freekmurze, I set up to S3 in a new different app using server pilot and run: php5.6-sp artisan backup:run
the response was:
Start backing up
[Exception]
Could not create backup of db
Exception trace:
() at /srv/users/serverpilot/apps/appname/vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php:44
Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler->getDumpedDatabase() at /srv/users/serverpilot/apps/appname/vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php:57
Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler->getFilesToBeBackedUp() at /srv/users/serverpilot/apps/appname/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:63
Spatie\Backup\Commands\BackupCommand->getAllFilesToBeBackedUp() at /srv/users/serverpilot/apps/appname/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:33
Spatie\Backup\Commands\BackupCommand->fire() at n/a:n/a
call_user_func_array() at /srv/users/serverpilot/apps/appname/bootstrap/cache/compiled.php:924
Illuminate\Container\Container->call() at /srv/users/serverpilot/apps/appname/vendor/laravel/framework/src/Illuminate/Console/Command.php:149
Illuminate\Console\Command->execute() at /srv/users/serverpilot/apps/appname/vendor/symfony/console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at /srv/users/serverpilot/apps/appname/vendor/laravel/framework/src/Illuminate/Console/Command.php:135
Illuminate\Console\Command->run() at /srv/users/serverpilot/apps/appname/vendor/symfony/console/Application.php:878
Symfony\Component\Console\Application->doRunCommand() at /srv/users/serverpilot/apps/appname/vendor/symfony/console/Application.php:195
Symfony\Component\Console\Application->doRun() at /srv/users/serverpilot/apps/appname/vendor/symfony/console/Application.php:126
Symfony\Component\Console\Application->run() at /srv/users/serverpilot/apps/appname/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94
Illuminate\Foundation\Console\Kernel->handle() at /srv/users/serverpilot/apps/appname/artisan:36

I also tried in both 5.1 and 5.0 so is another problem
Also how do we make sure the S3 destination is it writable? sorry about all this, but your package seems the best and I will really like to use it

@freekmurze
Copy link
Member

You could try putting a file on S3 with the configured Filesystem

Storage::disk('nameOfYourConfiguredFilesystem')->put('file.txt', 'Contents');

@nam-co
Copy link
Author

nam-co commented May 26, 2015

Hi Freek, thanks for your response, but I don't think the problem is in S3, because when I choose local it doesn't work, could the problem be the app is using serverpilot?

I try the Storage to S3 and it didn't worked, I change the key and it work, tried again the backup and still same problem (Could not create backup of db)

Thanks

@nam-co
Copy link
Author

nam-co commented May 26, 2015

ok, is not server pilot because I test in my local server using mamp and same error with both (local and S3)

@freekmurze
Copy link
Member

Are you sure mysqldump is installed on your system? Could you try running it manually to see if it creates a dump of your db?

@sethphillips
Copy link

I was facing this same issue, however only on a windows deployment. In development on my mac it ran fine. I had to set the default path for mysqldump in the config to "C:/Program Files/MySQL/MySQL Server 5.6/bin/" and then it worked.

@sethphillips
Copy link

Ive just ran into this on another windows server and the above solution does not work for it. I've verified that mysqldump does work on the system

@ilkermutlu
Copy link
Contributor

I recently had the same issue. (OS X, MAMP)

It turned out that my mysqldump path was incorrect. In my case a full path to the binary was provided. I replaced it with the path to the directory.

@naveenkumarmatturthi
Copy link

I too have same issue. Could any one help me?

@freekmurze
Copy link
Member

@RSNKumar could you try @ilkermutlu 's solution?

@anhtuank7c
Copy link

Resolution for error could not backup db.
You must setup environment path to mysql.
I'm use windows 7, and here my path to mysql: C:\Program Files\MySQL\MySQL Server 5.6\bin
I do copy this path and paste to System path environment,then click ok.

Open new Command Line then execute: php artisan backup:run
It's work like a boss.

@freekmurze
Copy link
Member

@anhtuank7c thanks! 👍

@lucidlemon
Copy link

i can't get it running either.

php artisan backup:run --only-db -vvv
Start backing up



  [Exception]                    
  Could not create backup of db  



Exception trace:
 () at /var/www/staging/webshop/vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php:47
 Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler->getDumpedDatabase() at /var/www/staging/webshop/vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php:60
 Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler->getFilesToBeBackedUp() at /var/www/staging/webshop/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:67
 Spatie\Backup\Commands\BackupCommand->getAllFilesToBeBackedUp() at /var/www/staging/webshop/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:33
 Spatie\Backup\Commands\BackupCommand->fire() at n/a:n/a
 call_user_func_array() at /var/www/staging/webshop/vendor/laravel/framework/src/Illuminate/Container/Container.php:502
 Illuminate\Container\Container->call() at /var/www/staging/webshop/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
 Illuminate\Console\Command->execute() at /var/www/staging/webshop/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at /var/www/staging/webshop/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
 Illuminate\Console\Command->run() at /var/www/staging/webshop/vendor/symfony/console/Application.php:878
 Symfony\Component\Console\Application->doRunCommand() at /var/www/staging/webshop/vendor/symfony/console/Application.php:195
 Symfony\Component\Console\Application->doRun() at /var/www/staging/webshop/vendor/symfony/console/Application.php:126
 Symfony\Component\Console\Application->run() at /var/www/staging/webshop/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:100
 Illuminate\Foundation\Console\Kernel->handle() at /var/www/staging/webshop/artisan:36

Standard Filesystem settings, directory backups created, Laravel 5.1, ubuntu 14.04, also added it with ::class etc.. everything like it should.
I can also create a mysqldump as the www-data user myself from the command line, just not with this plugin.

Any ideas?

@REBELinBLUE
Copy link

Yep, exactly the same issue with Laravel 5.1, Debian, Standard config, created the backup directory, mysqldump is in the default location but I added it to the config as well just in case

I put a dd() on line 51 https://github.com/spatie/laravel-backup/blob/master/src/BackupHandlers/Files/FilesBackupHandler.php#L51 both includedFiles and excludedFiles are null for me

@Sarnodeep
Copy link

anhtuank7c thanks 👍

@adrinavarro
Copy link

I second this because I'm seeing this as well. Had it happen on a first setup, then after migrating the server it's happening again, and it takes hours of debugging because the error message and trace isn't really clear.

Now, back to figuring it out…

@adrinavarro
Copy link

Ooh. Seems the culprit is hhvm. Should not get the uri for stream_get_meta_data. A workaround should be feasible.

facebook/hhvm#2336

@jpscharf
Copy link
Contributor

jpscharf commented Nov 9, 2015

I am having the same problem, and I am not using hhvm:

Start backing up



  [Exception]
  Could not create backup of db



Exception trace:
 () at /home/forge/dev.essentialoils.org/vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php:46
 Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler->getDumpedDatabase() at /home/forge/dev.essentialoils.org/vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php:59
 Spatie\Backup\BackupHandlers\Database\DatabaseBackupHandler->getFilesToBeBackedUp() at /home/forge/dev.essentialoils.org/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:254
 Spatie\Backup\Commands\BackupCommand->getDatabaseDump() at /home/forge/dev.essentialoils.org/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:70
 Spatie\Backup\Commands\BackupCommand->getAllFilesToBeBackedUp() at /home/forge/dev.essentialoils.org/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php:35
 Spatie\Backup\Commands\BackupCommand->fire() at n/a:n/a
 call_user_func_array() at /home/forge/dev.essentialoils.org/vendor/laravel/framework/src/Illuminate/Container/Container.php:503
 Illuminate\Container\Container->call() at /home/forge/dev.essentialoils.org/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
 Illuminate\Console\Command->execute() at /home/forge/dev.essentialoils.org/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /home/forge/dev.essentialoils.org/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
 Illuminate\Console\Command->run() at /home/forge/dev.essentialoils.org/vendor/symfony/console/Application.php:838
 Symfony\Component\Console\Application->doRunCommand() at /home/forge/dev.essentialoils.org/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /home/forge/dev.essentialoils.org/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at /home/forge/dev.essentialoils.org/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107
 Illuminate\Foundation\Console\Kernel->handle() at /home/forge/dev.essentialoils.org/artisan:36

@ekstro
Copy link

ekstro commented Dec 3, 2015

In my case problem was with temporary config file for mysqldump (one generated with tmpfile() in dump method). When you defined host in Laravel config file as eg. "localhost:8889" (with port) this causing the problem.

[client]
user = 'root'
password = 'lopawq2012'
host = 'localhost:8889'
port = '3306'

This is working for me:

[client]
user = 'root'
password = 'lopawq2012'
host = 'localhost'
port = '8889'

@starship11
Copy link

is there any way to call the same artisan command from laravel controller?? when called from controller it gives error "could not backup db" :(

@freekmurze
Copy link
Member

@starship11 If you configured the package correctly you can use this code in your project to perform a backup.

\Artisan::call('backup:run');

@DerJacques
Copy link

I received the same error message, but in my case it was 100% my own fault.
Just for the record, I'm using MySQL and AWS S3.

  • If you are running Laravel in a VM, make sure to run the command from within the VM (or wherever mysqldump is installed).
  • Inserting dd($success) in /vendor/spatie/laravel-backup/src/BackupHandlers/Database/DatabaseBackupHandler.php on line 44 might provide you with a more detailed error message.

Not sure if my issue was related to the ones you folks are experiencing, but maybe this helps.

@freekmurze
Copy link
Member

@DerJacques Thanks for taking the time to post your solution 👍

@bloodyburger
Copy link

Start backing up
"mysqldump: Got error: 1045: "Access denied for user 'root'@'localhost' (using password: NO)" when trying to connect\n"

Why is it using root user and not the user specified in config file.

@freekmurze
Copy link
Member

Did you save your credentials in the config file?

@bloodyburger
Copy link

PDO::FETCH_CLASS, /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => 'mysql', /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => storage_path('database.sqlite'), 'prefix' => '', ], 'mysql' => [ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'thejanso_anand', 'username' => 'thejanso_anand', 'password' => 'wewewew', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ], 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'schema' => 'public', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', ], ], /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk haven't actually been run in the database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ 'cluster' => false, 'default' => [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 0, ], ], ``` ];

@bloodyburger
Copy link

do I need to make any changes.

Regards,
Anand

On 26 January 2016 at 04:49, Freek Van der Herten notifications@github.com
wrote:

Did you save your credentials in the config file?


Reply to this email directly or view it on GitHub
#37 (comment)
.

@DerJacques
Copy link

Do you have any other database config-files?
You might want to check if there's a different config in a folder called config/production or config/local.

Make sure that your Laravel database connection works fine otherwise. The error you experience does not necessarily seem to be related to this package.

@bloodyburger
Copy link

Hi,
I do not have multiple config files. I am using default installation only
and am able to run the site which uses this database. The database had
different user than root. Why root user is being picked and from where.

Regards,
Anand

On 26 January 2016 at 05:34, Manuel Thomsen notifications@github.com
wrote:

Do you have any other database config-files?
You might want to check if there's a different config in a folder called
config/production or config/local.

Make sure that your Laravel database connection works fine otherwise. The
error you experience does not necessarily seem to be related to this
package.


Reply to this email directly or view it on GitHub
#37 (comment)
.

@bloodyburger
Copy link

I am using hhvm, guess that is causing the issue. Any workaround or solution available yet.

@bloodyburger
Copy link

Fixed by changing Line 50 as highlighted in MySQLDatabase.php

capture

@devLopez
Copy link

Hi guys

I'm having a problem with the backup of database. When I run the artisan command on CLI, the database backup works perfectly, but I need run the backup command inside a Controller, and then, I receive error "Could not create backup of db".

How I can proceed?

God Bless

@freekmurze
Copy link
Member

@devLopez If it can run on the cli, it should work in the controller as well. Does your application is alle to connect to the database inside the controller? Could you show the code that you're using to run the backup command?

@devLopez
Copy link

devLopez commented Feb 2, 2016

@freekmurze, down, I took a print screen of my source code. I've created a controller only for manage my backup actions.

God Bless

backup-artisan-error

@freekmurze
Copy link
Member

Seems good. Are you sure it works on the cli? From a package standpoint there's no difference in calling it from cli or calling the command from your controller. I the problem is caused by something specific to your setup.

@devLopez
Copy link

devLopez commented Feb 2, 2016

@freekmurze

Works very well, take a look

error-laravel-db

@freekmurze
Copy link
Member

Is the process that handles your web requests allowed to execute external programs like mysqldump?

@devLopez
Copy link

devLopez commented Feb 2, 2016

Oh men, you got me!!!

I don't know, how I can see it?

@freekmurze
Copy link
Member

I'm not familiar with running php on windows.

@devLopez
Copy link

devLopez commented Feb 2, 2016

I'm thinking, backups generated manually can be a bad thing.
The user can forget it.
I'll do it working with cron jobs, is more secure.

God Bless you men, thanks

@jpscharf
Copy link
Contributor

Backup will fail if the port is included/inlined with the host, e.g DB_HOST=localhost:3306.

  • The solution for my issue was to add DB_PORT to .env and 'port' => env('DB_PORT', 3306) to config/database.php

@freekmurze freekmurze changed the title Could not create backup of db L5.0 In version 2: Could not create backup of db L5.0 Feb 27, 2016
@freekmurze
Copy link
Member

I'm going to close this for now. If you have any more troubles with v2 of this package, try upgrading to v3

@devLopez
Copy link

devLopez commented Mar 9, 2016

Ok men

@nam-co
Copy link
Author

nam-co commented Mar 9, 2016

thanks for v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests