We have a large Yii2 / PHP application using MySQL database and versioned by GIT. The application is under continuous development as customer require new features. The database gets changed quite frequently. The application is versioned using GIT (each production version gets a new GIT tag) and backuped on a daily basis.
When something fails we need to restore one of our latest database backups. Sometimes in case if database problems the restore fails because of recent application updates. And the other way round (this was not yet the case, luckily!): if the application fails (e.g. the server gets hacked) we need to know which GIT tag the database belongs to.
How can we assure that the database and the application are in sync?
Are there scripts or best practices around?
BTW: We don't want to include the database backup in the git versioning (see here)