we want to synchronize the s3 media bucket from Production to the Test environments and we are thinking to use S3 Replication. However the DB will be synchronized twice at year though. Would that work?
Should the S3 bucket be in sync with the DB or it's not needed?
With your restriction (de-coupled media and db sync) I'd try the following:
0. Configure the S3 replication
Now media binary sync can be ignored for the next steps and only the state of the DB has to be taken in consideration. Problem is that the creation of media files will fail when dataPk is already taken.
1. Restore production DB Dump on test system (with all necessary anonymization)
2. Adapt dataPk counter by adding an offset (e.g. 10 million) to the current counter value.
3. Start sap commerce
Insights on dataPk
For the dataPk the same numberseries is used as for the Media PK itself. (Media Type Code = 30). The value in question can found with
select * from numberseries where serieskey = 'pk_30'
When it comes to SAP commerce it is recommended to have DB and Media storage not diverging and more important anonymize production data.
The problem which may occur is that the mediaPK for a new entry is already taken by a file on the storage. When this happens the creation of new media fails. It is not that problematic when the media storage is behind the DB then only some medias can not be loaded.
Therefore SAP created a snapshot restore feature which takes this in consideration for CCv2. https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/0fa6bcf4736c46f78c248512391eb467/f777fc0a4...
Hint: To avoid the collision during media creation it is possible to increase the counter of the mediaPK (this is not the PK of Media entity) to the current number of production database.