I have created a command in a laravel app which is supposed to call dumpmysql command and gzip content in a file.
in other words, i get the DB user password and database name throught \Config class and call exec php function to do this (with the Process Symfony Class) :
$process = new Process(
"mysqldump --user='%s' --password='%s' %s | gzip > %s",
config("database.connections.$this->connection.username"),
config("database.connections.$this->connection.password"),
config("database.connections.$this->connection.database"),
storage_path($filename)
)
try {
$this->process->mustRun();
$this->info('The backup has been proceed successfully.');
} catch (ProcessFailedException $exception) {
$this->error('The backup process has been failed. : ' . $exception->getMessage());
}
I have tested this in my local environment (Linux subsystem on windows - WSL) and in an preproduction environment (debian) and it works like a charm. But for an unknown reason, when i use this on my production server (which is also a debian), the script runs without error, but sometimes I have no file at the end. I had one or two time a file, but 90% of my tries ended with no error but no file.
On preproduction and production, the raw output (not zipped) is a 1.6G file, which become a zipped file of approxmatively 130MB. I have enough disk space on my system.
I would appreciate any help because I could not find any explanation. I read somewhere that the ">" operator may not work with exec but it works on other environment, so I don't think this could be the reason.
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire