Downgrading Shopware in case of accidental update

How you may be able to safely downgrade your Shopware installation in case you accidentally updated.

557 views
d

By. Jacob

Edited: 2022-07-29 15:15

An unfortunate rule of thumb that also holds true for Shopware is that downgrading is usually not a good idea – but that does not mean that it is not possible.

Sometimes an update might be insignificant enough for us to downgrade relatively easy if something is not working. Shopware plugins are notorious for breaking when Shopware is updated, so it is important you test updates on a development server before you apply an update on production.

I accidentally updated 6.4.11.1 to 6.4.12.0 by running composer update; luckily I was able to Downgrade simply by restoring the old files from a backup. It did not seem like there was any incompatibilities in the database itself, and the system itself was running fine afterwards.

If new files has been uploaded to the system in between your last backup and the update, you can just delete everything excluding the content, and then simply skip existing files when extracting the backup file.

Note. Before you do anything, it is still a good idea to make a backup of your files and your database so that you can easily retry, in case anything does not work after downgrading.

Handling backups

I am assuming you have some sort of backup system in place, and that you already have a backup file you can restore from. In my case this was a tar.gz file, which is really just a gzip compressed tar file – the advantage of tar files is that permissions are preserved.

To extract a tar.gz file you may use this command combination:

pv ~/backups/backup-of-files.tar.gz | sudo tar -xz -C /path/to/destination/directory

The pv command will show a progress bar while tar will do the actual extraction.

  1. -x = extract the file.
  2. -z = reads the archive through gzip.
  3. -C = tar will change to supplied directory before extracting.

If you are lucky, you may not need to do any database fixes – probably often the case with minor updates.

Creating a backup

If you need to create a backup, use this:

sudo tar -zcpvf /srv/backup/files.tgz -C /srv/shopware .

Note. The dot at the end is important! It makes sure that only relative paths are included in the archive.

After downgrading

When downgrading Shopware, or anything really, you run the risk of causing errors in the system, hence why creating a backup is so important, even if your updated system is broken or has incompatible plugins. Having a backup of the system means you can always try other ways of downgrading if your first attempt fails.

Even if the system appears to be broken, it is probably less broken than you think, and there is a fair chance you will be able to fix the errors. So, do not give up just because it seems broken. Read the error messages in the log file, and try to assess if your skill level allows you to fix it within a reasonable amount of time.

Sometimes it may be faster or easier to simply restore from a backup and re-upload any content that may have been added after updating, including orders and new customers.

Tell us what you think:

  1. Sometimes we may to manually clear cached Shopware files to fix namespace issues.
  2. How to obtain the currently selected API language from Shopware vue components.
  3. How to access file system paths from storefront twig files in Shopware.
  4. How to get or change the currently selected sales channel in an Shopware sw-sales-channel-switch component.
  5. In this tutorial you will learn how to work with Shopware entities in a generic way from PHP, without having to specifically inject the repository in your services.xml file.

More in: Shopware