mysqldump saves files as 20B only on production, my localhost is Okay, both use MySQL8

Viewed 44

I am having a challenge with my database automated backups.

Each time I run the backup command from the system the files are saved as 20B files yet the files are larger than that.

I am experiencing the issue only in the production environment(Centos 7), my localhost is Okay.

This was initially working but after a series of updates on the server it stopped working, I am not sure why.

Below is the backup snippet(Laravel PHP):

            //set filename with date and time of backup
            $file_name = Carbon::now()->format('Y-m-d-H-iA') . ".sql.gz";
            $file_path = $this->file_storage_dir . "/" . $file_name;

            File::ensureDirectoryExists($this->file_storage_dir);

            //mysqldump command with account credentials from .env file and file path
            $command = "mysqldump --column-statistics=0 --user=" . $username . " --password=" . $password . " --host=" . $host . " --all-databases | gzip -c > " . $file_path;

            $return_status = null;
            $dump_output = null;
            
            //exec command allows you to run terminal commands from php
            exec($command, $dump_output, $return_status);
1 Answers

A delayed solution. (This fixed my problem).

Might have forgotten to mention this;

I had recently updated my Web App architecture and separated the database and application services to two separate servers.(Application & Database Servers)- for scalability reasons.

Then cleaned the App server and removed mysql as I did not need it.

I am running my backup command (mysqldump) from the Application Server therefore had to install it back.(Though Redundant)

If anyone has a better idea. You are welcome..

Many thanks.

Related