We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28338
    • 46 Posts
    Hi.

    How could I import parts of the database from another modx installation into my current one? One division of the company has been running modx for a while and I would now like to import their work into the main modx installation.

    Thanks in advance

    Anders Milton
      • 4673
      • 577 Posts
      Just an off hand reply,

      It’s loads of fun!

      export your db and the other and go ahead and cross cut the data. Watch out for all the fun stuff like users, templates, content, etc ... expecially in regards to the db FIELD IDs.

      hmmm, if possible use the older data to base your newer site on would probably be the quickest and easiest.

      I hate porting data from one db to another sad
        Tangent-Warrior smiley
        • 22815
        • 1,097 Posts
        Some initial questions that will make answering this easier:

        1) What experience of importing databases do you have?
        2) Do you have access to phpMyAdmin? If not, what db management facilities do you have?
        3) What parts of the data do you want to import?
        4) How many users are there in each MODx install?
        5) Are they both running the same version of MODx?
        6) How much work is there to import, in terms of pages and templates etc?
        7) How complex are the pages?

        If it is just content that you need to import, you may find the Export Site / Import Site functions will do everything you need.

        But backup everything first.
          No, I don't know what OpenGeek's saying half the time either.
          MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
          Forum: Where to post threads about add-ons | Forum Rules
          Like MODx? donate (and/or share your resources)
          Like me? See my Amazon wishlist
          MODx "Most Promising CMS" - so appropriate!
          • 28338
          • 46 Posts
          Quote from: PaulGregory at Jun 14, 2006, 03:21 PM

          1) What experience of importing databases do you have?
          2) Do you have access to phpMyAdmin? If not, what db management facilities do you have?
          3) What parts of the data do you want to import?
          4) How many users are there in each MODx install?
          5) Are they both running the same version of MODx?
          6) How much work is there to import, in terms of pages and templates etc?
          7) How complex are the pages?

          If it is just content that you need to import, you may find the Export Site / Import Site functions will do everything you need.

          1) Not very much
          2) I guess it would be possible to install phpMyAdmin. Not a problem
          3) It’s pretty much just the content, so no templates.
          4) Not that many users.
          5) Well, one is running 0.9.1 and one is running 0.9.2, but there should be no problems upgrading.
          6) A hundred or so pages, no templates.
          7) Not at all. Some formatted text and some images.

          So I guess I should go for the Export Site / Import Site. Does that automatically put the imported pages in folders and do they get the right long and short titles?

          And to Carsten: Do you sound bitter or what?! smiley

          /Anders
            • 18436
            • 135 Posts
            I’m not 100% up to scratch with SQL but I face synchronising a local and live db each month when I put a new issue of my site up. The tool I found most useful is SQLYog which has a db synchronisation tool. One word of advice: keep a backup of each db you’re trying to synch!!!

            If you’re up to scratch on sql queries you could most likely build a custom one to import all records from tbl site_content but I get a bit lost with all the related tv and keyword table records.

            Is there anyone on the dev team who can actaully let us know which tables relate to content (site content and any related fields) to make db synchs easier.
              • 22815
              • 1,097 Posts
              @Marschant: This is not a sync, it is a merge. I assume that some of the Division Site’s 100 pages have the same IDs as some of the Main Company Site’s pages. Can SQLYog tell the difference between an updated page and an entirely different page?

              @staed: I don’t know if the Import / Export keeps all the Long Title etc information as I’ve really not tried it yet. However if you have little database merging experience it is probably easier to rekey in all the Long Titles than it is to change a bunch of page IDs. Also, you can probably get someone else in your company to do that far easier than you can get someone else to merge databases!

              As you have no fancy templates, and your pages are not complex, I assume that your images are just in the main content block. If you had lots of custom TVs for images etc or if you were heavily using keywords then this would definitely be a case for a database import.

              General thoughts on importing db data:
              I can see how it would be exceptionally useful for there to be an all-singing all-dancing MODx plugin that could smart-import data, eg checking to see if a user already exists and either replacing userID 10 with existing userID 7 or new userID 45 as appropriate. And offering for every different page the option of Overwrite / Ignore / Add As New. But until I need it myself, I won’t write it, especially given that there are likely to be changes in 1.0.

              The simple way to avoid overwriting content when merging is to offset every ID in the Division website by the largest ID number in the Main Co site. My SQL knowledge is basic, so I’d end up writing a PHP script that went through each table (in descending order of existing ID) and changed each ID to ID + LargestNumberFromTargetSite. Again, I don’t actually need this myself so I won’t write it, but hopefully the suggestions are helpful to someone.
                No, I don't know what OpenGeek's saying half the time either.
                MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
                Forum: Where to post threads about add-ons | Forum Rules
                Like MODx? donate (and/or share your resources)
                Like me? See my Amazon wishlist
                MODx "Most Promising CMS" - so appropriate!
                • 28338
                • 46 Posts
                Thanks for the answers. I haven’t yet decided which way I will go, but I will sure figure something out.

                /Anders
                  • 18436
                  • 135 Posts
                  An exceptionally tricky situation indeed, my brain falls over when I try and think of a solution to maintain the relationship between template variable table records and site_content id’s.
                  One methodology that a buddy showed me was to do a sql select on all columns then use that result set and insert it into the target db but omitting the id field, that’s kind where things fall over.

                  All I can say until someone more knowledgable comes along is: good luck man!

                  @PaulGregory: I’m not sure about SQLYog’s total feature set but it’s a free tool that he could try out.