Category Vanished, Trying to locate and Rollback

Hi,

So randomly, I have lost a category. It was there 2 days ago, now its gone. Could have been caused by an SEO module, not sure, don’t really care, just want to restore the category so I can then try replicate the error on the dev site.

So I have a backup job that runs daily, it does a backup of “Database and Media” which was setup via backup GUI. Viewing the list of backups I can see “1595296802_media.tgz” backups for every day. So when using the GUI to perform a rollback, I get the error “You need more permissions to perform a rollback.”

So naturally believing it is a permission problem, I reset the permissions following your guide Attempted the roll back again, it failed with the same error.

So I am thinking of trying to use the command line approach, I believe the issue is database only, so I am running the command

bin/magento setup:rollback -d 1598061602_media.tgz

However that fails with the error “The rollback file is invalid. Verify the file and try again.”

So I thought I would download the backup and manually replace the database using PHPMyAdmin, however I cannot find the database backup in the ZIP. Maybe someone knows where it is?

Is it possible to view the categories in the database, and see if this missing one exists?

So right now, I am stuck…

Do you have any other ideas I could attempt?

The command you referenced it telling Magento to rollback the database using the media file as reference and not your database file. Your database backup will end .sql.

Database only

bin/magento setup:rollback -d 123456789_db.sql

Media only

bin/magento setup:rollback -m 123456789_media.tgz

Thanks Craig

So then a database backup has not been working as described in the GUI. doh!

You mean it hasn’t been backing up? :tired_face:

I know this doesn’t solve your issue now, but I would recommend backing up your database in future the traditional way (which does not rely on Magento).

Variables

  • myql_username - e.g. magento or root
  • mysql_database - Magento database name
  • mysql_backupfilename.sql - Filename you want to save as

MySQL Dump (Backup)

mysqldump -p -u myql_username mysql_database > mysql_backupfilename.sql

MySQL Import.Restore

mysql -p -u myql_username mysql_database < mysql_backupfilename.sql

Notes

  • Both commands can take 1-2 minutes to complete - Meanwhile the terminal may appear frozen.
  • The file will output from whatever directory you happen to run the command from
  • I think you might have to do this as the MySQL root user these days (as opposed to the Magento MySQL user) due to a security update. But you might want to fact check this.
  • You could implement this as a cron job alongside a logrotate task to run on a schedule and only keep the last X days worth of backups. I won’t be going into that here though.
  • Traditional MySQL dump files are “tampered” with, where as Magento backups implement some weird header which stops you from doing a traditional import without having to mess with the file somehow.

Thanks for the pointers.

No idea how that category and sub-categories got lost, none of the module owners are admitting there module could do such a thing. Checked access logs and everything, no one else been on the site but myself. Seems odd as all products was there!

Well SQL backup is working now. I will test a restore on my dev site, then try a production one. Took the command line and cron route as recommended.

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.