4

Our client build tons of articles in our craft system instead of his. Both systems have the identical structure, in fact, his system is a exact copy of ours, which runs on a different server. How can we move all his content on our craft system into his system?

(As you may have noticed I am not a developer. I hope you get what my problem is here ... )

1
  • @brad-bell do you have any recommendation? We have 2 environments TEST and PROD. Each environment has different set of users /permissions, graphql keys, SSO integration, redirects. Simply importing whole DB drops environment specific values.
    – dhumketu
    Commented Apr 11, 2023 at 18:09

3 Answers 3

4

This can be a challenging situation. Craft content can be highly relational which makes it tricky to just export and re-import.

Scenario 1: If your database and your clients database were both equivalent before your client added the additional content, you may be able to just migrate over your clients database and replace your own database and get both back in sync.

To migrate the database would involve exporting the database from the clients environment (either via Settings->Tools->Backup Database or via a database admin tool) and reimporting it into your environment with a database admin tool.

Scenario 2: If both you and your client made changes to your respective databases (for example, you both added articles in each environment) and you need to preserve the new articles added in your environment while also migrating over the articles added in the clients environment you have two options.

First, you could just manually re-enter the articles in the right environment. As it sounds like your client added a lot of articles, that might be time consuming, but sometimes these types of mistakes take time to correct manually. It's often the best option.

In the case you added a few articles and your client added many articles, it may make more sense to add your articles to your clients database and then migrate the full database back to your servers as described in Scenario 1.

Your second option would be to migrate the content programmatically. This becomes a bit more technical so you'd probably need to get a front-end or back-end developer involved. And it will only make sense to go this route if the quantity of data you need to migrate is too much to just do manually.

A plugin like Sprout Import can help with this scenario. (Full disclosure, my team developed Sprout Import.) The steps would involve outputting the content from your clients database into a template into an importable JSON format. And then importing the content defined in the JSON file into your database. The docs and examples within the plugin would go into more detail about the exact format you would need. For this answer, the more general point is that if your data was complex enough, a database migration plugin like Sprout Import could help provide a path toward a solution.

1

You should be able to back up the database in the Settings panel in your version of Craft, and then drop the database on his server in PHPmyAdmin and load in the backup. This will replace everything on his server with what's on yours.

1

If your systems are exactly the same, you should be able to:

  1. back up the Craft database for each system: client and 'ours'. This is your protection against errors or unknown issues, so don't skip it please.

  2. if your backup isn't a kind to create a full structure and content sql file for each database, make this kind of backup also, for safety and for the actual transfer of content that you want. A tool like Navicat should make this very easy, but your database administrator will know how.

  3. you're fully backed up, right?

  4. on the 'client' system, delete all tables in the Craft database, or drop the database itself, in which case you'll have to re-create it,set utf8mb4 character and sort, and add back allowed users. Again, a tool like Navicat can make this easy, and your database administrator should know how.

  5. with the now-empty 'client' database, execute (play back) the structure and content sql file from the 'ours' system, that you createdd in step a) or b)

  6. now the 'client' system is running with the same data as the 'ours' system, so you will have successfully transferred the work they did there.

Caveat. If the client actually did some work on their system, like setting up users or adding/changing content, this would be lost.

Recovering it from the backup won't be possible, as complex record identities and relations won't be the same. The way to prepare for this is to re-key any extra work like this into the 'ours' Craft system, before you do the backups and start the above procedure. If you don't prepare this way, then you can re-key on the client system after you've moved the 'ours' data to it as above.

I think I've covered everything, but have your database administrator look at these notes and have a think about it.

Good fortune, and since you're near the beginning, probably the worst that could happen is to need more re-keying.

This procedure is the one many developers use all the time -- it's standard.

If you have doubts, please don't use this process; instead, re-key the missing work, as that will be safest.

If the procedure fails, you will have your structure-and-content sql file, and can replay it into the client database after emptying it again, to restore the current situation. Or use your other database backup restore method from step a), if there was one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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