1

We accidentally deleted all our body text on all our pages, how do I redo my website to a older version. (24 hours ago) We changed matrix to assets and after that every body text disappeared.

2

As John mentioned, restoring a database backup is your best bet.

If you don’t have a recent backup, you may still be able to get your Matrix content back, thanks to semi-bug where Craft doesn’t actually delete Matrix block content, when a Matrix field is converted to something else.

Here’s what you can try:

  1. Enable the Project Config file for your site, if you don’t already have it enabled.

  2. Figure out what your field’s uid is by looking up its row in your database’s fields table.

  3. Find the most recent project config backup in storage/config-backups/ where your field was still a Matrix field. The most recent backup will be called project.yaml, the second most recent will be called project.yaml.1, and so on. For each file, search for <field-uid>: (replace <field-uid> with the UID from step 2). If the nested type property is set to craft\fields\Matrix, you’ve found the right file. It will look something like this:

8823155c-e84a-4a38-af30-2cb88b705e7b:
  name: Body
  handle: body
  instructions: ''
  searchable: true
  translationMethod: none
  translationKeyFormat: null
  type: craft\fields\Matrix
  settings:
    maxBlocks: '3'
    localizeBlocks: false
    contentTable: '{{%matrixcontent_testimonials}}'
  fieldGroup: d58a1faa-0bf6-46b2-b880-b0c14bebca75
  contentColumnType: string
  1. Find the same field definition in your current config/project.yaml file, and replace it with the field definition from the backup you found in step 3.

  2. As a sanity check, you may want to compare the config backup from step 3 with the subsequent backup (so if you found your matrix field in project.yaml.10, compare it with project.yaml.9), using a diff tool like FileMerge (comes with macOS) or Kaleidoscope. If there are any other significant changes that happened at the same time, you may want to revert those changes as well in config/project.yaml.

  3. Now access your Control Panel and click the button to sync your new project.yaml changes. When that’s done, if all goes well, your field should be a Matrix field again, and your content will be restored. 🤞🏻

| improve this answer | |
1

Restore your database from a recent backup is your only real option tbh.

| improve this answer | |
1

'allowAdminChanges' => false on your production server is also a tip I can give you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.