4.3.1 To 4.3.2 Upgrade > How To Disable Automatic Database Backup While Updating

we are currently running 4.3.1 ultimate and want to upgrade to 4.3.2… problem is that when we try to upgrade using the upgrade center, it auto starts taking full databse backup. which needs a huge amount of time as our database size is about 10gb. also i have manually taken the db backup by ssh which was much faster.



now how can i upgrade from 4.3.1 to 4.3.2 and disable the auto database backup feature?



Naman

Please try the following solution (Not tested (!))

Open the app\Tygh\UpgradeCenter\App.php file and replace:

$backup_file = DataKeeper::backup(array(
'pack_name' => $backup_filename,
'compress' => 'zip',
'set_comet_steps' => false,
'move_progress' => false,
));

with

$backup_file = DataKeeper::backup(array(
'pack_name' => $backup_filename,
'compress' => 'zip',
'set_comet_steps' => false,
'move_progress' => false,
'db_tables' => array(),
));

I had the same issue and can confirm that eComLabs' solution fixes this, thank you once again!



Please note that, like all changed files, the app\Tygh\UpgradeCenter\App.php file will be overwritten during the upgrade, so if you're having the same problem next time, you will have to add the line again.

I am glad to hear that our solution helped you.

I tried this solution but i get the same error. Can you help?

I tried this solution but i get the same error. Can you help?

What error do you mean?

Removed

I removed what I had written in my previous post because as of 4.3.10, the db_row was changed to 400 and the upgrade doesn't timeout anymore. I still stand on the same idea. If the number of rows in a table is more than a real high number, the db_row figure should be flexible to accelerate backup.

why didn't I think of searching for this weeks ago it would have saved me so many hours.

As I'm going through multiple releases to get to the current I don't really care about the backups, if it fails I just go to the manual backups.

thanks, really would be a nice option to have in the upgrade setting

You are welcome. In the latest versions there is an ability to skip backup. Check the following article

https://docs.cs-cart.com/latest/upgrade/upgrade_process.html

Hi all the fix to include db_tables => array() has been working but since I'm now on 4.4.1 things seem to have slow down again, is there any way to exclude backing up files as well, people have said it should be an option but I don't get that option presented on the screen to select.

thanks

Don't remember exactly when (what version), but if DEVELOPMENT is true, then there is a checkbox to skip the backup of db tables and files.

Thanks, any pointers to where development flag is set? ( OK got it thanks )

thomas

Usually best to do it in a local_conf.php file with code like:


Replace 'first ip', etc. with your IP address and set others as needed. You can comment out the ini_set() if you don't want errors/warnings/notices displayed to the screen of the user who's IP is a match.

You can get fancier with what SERVER elements are checked for the IP address in case you use a proxy server, or other details. But the above is the basics. Note that if cs-cart support comes to your site to help you they will overwrite this file and not clean up by replacing it when they leave (that gets old really fast).

Thanks, any pointers to where development flag is set? ( OK got it thanks )

thomas

See my post #10

Hello, after trying this method to upgrade from 4.17.1 to 4.17.2 it didn’t work just by adding:

'db_tables' => array(),

…to the params array here:

$params = DataKeeper::populateBackupParams(array(
    'pack_name' => $backup_filename,
    'compress' => 'zip',
    'set_comet_steps' => false,
    'move_progress' => false,
    'extra_folders' => array(
        'var/langs'
    )
));

It seems that the populateBackupParams() method is relatively new and is overriding the ‘db_tables’ key setting the database to still be backed up causing the database backup to break the execution if it is too big.

However I’ve noticed that adding the following code right after it, I forcefully re-empty it, and that worked fine in my case:

$params["db_tables"] = array();

So in order not to have to go through this fix every time I need to upgrade my customer’s cs-cart I wrote a simple script to do this for me and saved it as fix-upgrades.php in the root directory of cs-cart installation:

<?php

$original_file = __DIR__ . '/app/Tygh/UpgradeCenter/App.php';
$backup_file = __DIR__ . '/app/Tygh/UpgradeCenter/App.bak.php';

$fix = '$params["db_tables"] = array();';
$fix_before = '$db_path = DataKeeper::getDatabaseBackupPath($params[\'db_filename\']);';
$report_message = '<br>Please report your result here for support: <a target="_blank" href="https://forum.cs-cart.com/t/4-3-1-to-4-3-2-upgrade-how-to-disable-automatic-database-backup-while-updating/34503/14">https://forum.cs-cart.com/t/4-3-1-to-4-3-2-upgrade-how-to-disable-automatic-database-backup-while-updating/34503/14</a>';
$manual_revert_description = '<br>Open file:<br>' . $original_file . ' and remove the following line:<br>' . $fix;

//Checking if fix is already applied
$loaded_data = file_get_contents($original_file);
$fix_found = strpos($loaded_data, $fix);

//?revert action
if (isset($_GET['revert'])) {
    if ($fix_found === false) {
        die('The fix has not been applied yet, there is no need to revert.');
    }
    if (!file_exists($backup_file)) {
        die('Backup file not found! Please revert changes manually.' . $manual_revert_description);
    }
    if (copy($backup_file, $original_file)) {
        die('Reverted the backup file successfully!');
    } else {
        die('Backup file could not be reverted.' . $manual_revert_description);
    }
}

//Prevent double firing
if ($fix_found !== false) {
    die('The fix has already been applied! Please try to upgrade.');
}

//Take a backup
if (copy($original_file, $backup_file)) {
    echo 'Backup taken at:<br>' . $backup_file . '<br>';
} else {
    die('Could not take a backup of the original file at:<br>' . $backup_file . $report_message);
}

//Identify fix location
if (strpos($loaded_data, $fix_before) === false) {
    die('Fix location could not be identified!' . $report_message);
}

//Prepare the fix
$fixed_data = str_replace($fix_before, $fix . PHP_EOL . '                ' . $fix_before, $loaded_data);
if (file_put_contents($original_file, $fixed_data) === false) {
    die('The fix has failed to be applied!' . $report_message);
}
die('The fix was applied successfully! Please try to upgrade.');

Then I can apply the fix directly by calling the url at:
[domain.ext]/fix-upgrades.php

And it keeps a backup so I can revert the change using:
[domain.ext]/fix-upgrades.php?revert

I have placed basic checks to prevent double execution, reverting in case the fix has not been applied yet and prevent applying the fix at all if the following command is not found as it should be so that it doesn’t break anything in future updates if that changes:

$db_path = DataKeeper::getDatabaseBackupPath($params['db_filename']);

In case something doesn’t work as intended it points to this thread so that we get it figured out.
If you think there’s something not right with my script please let me know in order to correct/improve it.

I hope this helps you as it did with me.

DISCLAIMER:
Please take into account that I’m sharing this script in order to contribute to a solution for this specific issue. I will not be held responsible for any damage caused by it. Use it at your own risk, only if you can follow along with what it does, preferably in a testing environment prior to running it in a production instance.

1 Like

In the latest versions you can just enable the development mode and you will see the Skip backup checkbox during upgrade process

I’ve noticed that checkbox and used it on previous updates, however in this particular case the checkbox did not show up during the update steps.

That’s why I went ahead and manually disabled the db backup.
Are there specific updates that do not allow that option?

If I recall, the option is available on service packs only.

1 Like

It is available for all upgrades. But the development mode should be enabled