Blossom your business with savings! From 5th to 12th March, use the promo code SPRING24M and get a 10% discount on any module
Shop Now

How to do a Magento 2 upgrade? Techniques for keeping Magento up to date

The situation in the e-commerce market has brought Magento 2 to the position of one of the most utilized software solutions. The key reason for this is the dependability of this platform, which attracts online store owners.

Magento is capable of providing a serious level of safety, which means that store owners and website admins can feel secure. In addition, shop visitors are also protected if the latest software versions are used in the store.

Keeping the store software up to date is a rather straightforward process, which will not cause any reasons to worry.

Step 1. Be sure to backup Magento files and database

In any case, backup the files and database before making any changes to the store.

Store owners who use previous Magento versions can check if they have built-in backup tools by navigating to Admin > System > Tools > Backups.

If you do not have this menu, it means your store is using one of the recent Magento versions with depreciated built-in backup functionality. Read on how to do a Magento backup in our post.

In order to make a full backup, several Magento sections must be copied to a safe location.

Backup of Magento system. This type of backup creates a full copy of the store database and Magento system files. Make a copy of the media folder to secure images and other multimedia files that were uploaded into the store.

Your particular configuration may not require full manual backup. In this case, copy of the data that is not included in the automated backup; for example, it could be the media folder.

Step 2. Activate the maintenance mode in your store

Maintenance mode is a special tool Magento uses to signal visitors that the content is not available due to technical reasons. Thanks to this mode, shoppers can know that they will be able to use the store again in the not too distant future.

When upgrading, it is strongly recommended to place the store into maintenance mode. Enable it through CLI php bin/magento maintenance:enable

When Magento is transferred into maintenance, a file .maintenance.flag is created in the var/ directory. Simply delete this file if you do not want or can’t disable the maintenance mode via CLI.

Step 3. Check Cron before starting the upgrade

Prevent any problems that may occur in a case some Magento component starts planned job through Crone while the store is upgrading. Check the Cron job list and stop tasks.

Step 4. Start the update

Magento offers several techniques for the upgrade process. Use the one that best suits your needs.

Composer for Magento Upgrade

Since the Composer is the main package manager for Magento, it is considered the best option for upgrading.

Create a backup file for the composer.json with cp composer.json composer.json.bak

Launch the update process with composer require magento/product-community-edition=XXX --no-update. Then, replace XXX with the Magento version you want to upgrade to.

A list of all Magento 2.4 versions can be obtained via composer show magento/product-community-edition 2.4.* --all | grep -m 1 versions

On the next step, update the fields of the composer.json to reflect the new name, version, description.

After finishing preparation, apply the changes with composer update

On the last step, use the commands:

rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf generated/code/*

These commands are required. They clear the Magento cache. Additionally, clear the cache of any other installed software, such as Memcached or Redis.

Once the upgraded Magento files are on the server, it is time to update the database using the bin/magento setup:upgrade command.

Finish the upgrade process with disabling the maintenance mode with bin/magento maintenance:disable.

Check that the frontend and backend of your store are working flawlessly.

Setup Wizard to Magento upgrade

Stores on older versions of Magento can use the currently depreciated upgrade method via Setup Wizard in the admin panel.

If your admin panel provides a Setup Wizard, follow steps 1, 2, 3. Then log in to the admin panel with an account that has a full level of permissions.

Navigate to System -> Tools -> Web Setup Wizard > System Configuration > Save > System Upgrades. Type in the obtained at Magento Marketplace authentication keys when asked.

The Setup Wizard provides explicit upgrade instructions to ensure an easy and smooth process. The Wizard can request an upgrade of the PHP version. Magento 2.0, 2.1, 2.2 and newer versions require different PHP versions.

Manual upgrade

For the experienced user, the easiest upgrade technique may be a manual update.

Download the package from the official Magento page and unpack it into the root folder of your Magento. Replace all old files with the new ones.

Using SSH connection to your store run:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento indexer:reindex

Do not enter a new command until the previous one is finished.

The above list of commands does all necessary actions for the upgrade process. This is how you update the database, dependencies and erase cache.

After completing all the above commands: 1. Check that the store works flawlessly on the frontend and backend. 2. Run the compatibility tests on the extensions, and upgrade them if necessary. 3. Check with the extension developer to clear this.

Loading...