Search code examples
laravelbackup

Backup with Spatie does not work on Windows


I'm trying Spatie to create a backup from a controller and it only works when I try to create a copy of only the files, but if I try to create a database copy an error occurs. However, from a console the copy of the files and the database is created correctly.

I think it may be due to not having access to mysqldum.exe or something, since at first I couldn't create backups from the console until I added the path to mysqldump.exe to the environment variables.

I am using Windows and XAMPP for development.

Does anyone have an idea what the problem is?

public function backup(){
    $exitCode = Artisan::call("backup:run");

    if($exitCode == 0)
        return 'Backup Creado Correctamente.';
    else
        return 'Ocurrió un error al crear el backup.';
 }

Solution

  • Apparently it was the environment variable. It is the only explanation I can find but I am not completely sure because after adding the environment variable in the Windows system I was able to make copies from the console, prior to this I could not.

    I stopped testing for a couple of days, during that time I turned off the computer a few times and when I returned to try creating backup copies with this package everything works very well. I can now create backup copies of files and databases without any problem. In conclusion I think it was the environment variable and the necessary system reboot. I mention this so that if it happens to someone, consider restarting the operating system.