schickling / laravel-backup

Backup and restore database support for Laravel 4 applications
MIT License
351 stars 51 forks source link

Call db:backup form route or controller? #38

Open thearabbit opened 10 years ago

thearabbit commented 10 years ago

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 commented 10 years ago

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

victorpierredev commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@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 commented 9 years ago

I faced this problem too try this

Artisan::call('db:backup',['dump' => 'theara.sql']);
4sh3 commented 7 years ago

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