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

Call db:backup form route or controller? #38

Open
thearabbit opened this issue Aug 5, 2014 · 6 comments
Open

Call db:backup form route or controller? #38

thearabbit opened this issue Aug 5, 2014 · 6 comments

Comments

@thearabbit
Copy link

I would like to call php artisan db:backup theara.sql with custom file name from route or controller like this:

// call with default file name
Artisan::call('db:backup'); // work fine

// call with custom file name
Artisan::call('db:backup', array('theara.sql')); // don't work

I do like this because i want to get file name after generate backup file.
And then i have problem when restore it

Artisan::call('db:restore, array('theara.sql'))

Pl help me.

@anton-ko
Copy link

try this
Artisan::call('db:backup',['filename' => 'theara.sql']);

@victorpierredev
Copy link

The suggested code by @anton-ko does not work for me, I get the following error The "filename" argument does not exist.

Worked when I've called as follows:

Artisan::call("db:backup", ["--filename" => "test.sql"]);

@z0d14c
Copy link

z0d14c commented May 20, 2015

none of the solutions provided here work for me -- I cannot seem to set a filename, with or without hyphens. I also cannot set a path, though I'm not sure if the filename parameter is meant to do that.

If I do use hyphens, I get the "filename" argument does not exist error. If I don't use hyphens, I don't get that error but it still doesn't work.

I can use the no-parameter version of the db:backup command with success.

@victorpierredev
Copy link

@z0d14c If it helps, this is what my code looks like, and it is has been working for me sense November of last year (I make frequently backups).

Artisan::call("db:backup", [
            "--filename"   => $filename,
            "--gzip"       => "",
            "--local-path" => $fileLocation,
            "--cleanup"    => ""
        ]);

@agungjk
Copy link

agungjk commented Jul 10, 2015

I faced this problem too
try this

Artisan::call('db:backup',['dump' => 'theara.sql']);

@4sh3
Copy link

4sh3 commented Aug 23, 2017

This is not working for me, please help:

$execValue = Artisan::call("db:backup", [
"--destination" => "dropbox",
"--destinationPath" => "/db_",
"--timestamp" => "Y-m-d H:i:s",
"--compression" => "gzip",
]); // THIS IS NOT WORKING :(

I am creating backups with schedule using but what I want to do is force the backup in some specific times.

$schedule->command('db:backup --database=mysql --destination=dropbox --destinationPath=/db_ --timestamp="Y-m-d H:i:s" --compression=gzip')
->twiceDaily(8,18); // THIS IS WORKING

  • SOLVED:

    $execValue = Artisan::call("db:backup", [
    "--database" => "mysql", // This missed
    "--destination" => "dropbox",
    "--destinationPath" => "/db_",
    "--timestamp" => "Y-m-d H:i:s",
    "--compression" => "gzip",
    ]);

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

6 participants