We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37131
    • 111 Posts
    I've searched forums but could not find satisfactory answer to this:

    How to update you already running site with new version of this site, which was developed locally. Updating files is obvious, but how to update database and not loose already created content (posts, comments, users, their data, etc.) ?
      ---
      Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
      • 3749
      • 24,544 Posts
      If there have been changes to both sites, the only truly safe way I know of is to open the Manager for both sites in separate browser windows and cut-and-paste the changes from the local site to the remote.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 37131
        • 111 Posts
        This still doesn't sound too safe. People really work this way with MODX ?
          ---
          Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
          • 3749
          • 24,544 Posts
          I can't speak for others, but I've done it for years with no trouble. I update Bob's Guides all the time while it's live and I think most MODX users do the same. Nobody is taking their site down just to edit a page in the Manager.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 10208 ☆ A M B ☆
            • 1,780 Posts
            You could uncheck the cacheable box, and also the clear cache box in the resource. Then (as long as CacheMaster isn't installed) you could update the page, not clear the cache, view the page but it wouldn't update the site till you cleared the cache and made the resource cacheable.

            Right?
              Frogabog- MODX Websites in Portland Oregon
              "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
              Having server issues? These guys have MODX Hosting perfected - SkyToaster
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It's a lot easier to just leave the resource unpublished; you can still view it as a logged-in Manager user. Or use Stagecoach if you want to edit existing resources. That is my latest happy find. Thanks, BobRay!

              I usually have an unpublished resource "Susan Testing" that I keep at the bottom of the resource tree, and do all my testing of resources, snippets, and what-have-you on resources kept there. Revo with its drag-and-drop Tree makes it much easier to properly place anything once it's finished.

              Actual PHP code, snippet or plugin or CMP development, of course I don't do on the live server. That I do on a basic installation on localhost (or on the Cloud nowadays). But actually using a known working snippet, getting its output formatted and styled correctly, I test on the live site in my testing resources.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 37131
                • 111 Posts
                I don't really worry how to update but what to update - how to find what has been changed between dev site and live site and how apply differences. Thanks Susan for your tips smiley

                I just thought that site's logic in MODX is more separated from site's content. [ed. note: khyrlik last edited this post 13 years, 8 months ago.]
                  ---
                  Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
                  • 9207 ☆ A M B ☆
                  • 2,475 Posts
                  It's really the same song and dance no matter what database-driven web application you're using:

                  1. Make a full backup of the site's files and the database
                  2. Download the .zip of the new version to your server (preferably you have command-line access for this)
                  3. Extract the zip file, then overlay its contents over the existing files. Again, this is 100 times easier via the command line. Use a recursive copy command to merge directories:

                  \cp -fr modx-new-version/* /path/to/existing/modx/html


                  4. Run the setup via your browser: http://yoursite.com/setup and follow through with its steps.

                  To clarify a couple of your concerns:

                  1. this approach (although manual), can be less prone to error compared to updating via a web-request. Your web-server may not have the correct permissions to update all files and directories, and chaos can ensue if you try to let Apache/PHP run your updates for you.

                  2. The site's logic is 100% separated from the content in MODx: all content is in the database. Logic is all in files.

                  3. Database updates happen in the setup step above. But they can happen on the fly... Because the DB is abstracted via xPDO, new tables can be added as needed and they don't necessarily require a special setup step.
                    • 9102 ☆ A M B ☆
                    • 318 Posts
                    The site's logic is 100% separated from the content in MODx: all content is in the database. Logic is all in files.

                    To be fair, this is only true if you're not storing any snippets in the database. In most cases, there is probably at least some PHP code in the database in the snippets table.

                    You said what might have changed on the live site: resources, users etc. But what changed on the dev site? If it is just chunks, snippets and templates, you might be able to export those tables and import them into the live database (after making a full backup, of course).

                    Having said that, I generally work with unpublished resources on the live site when redesigning. That way you can make new templates, make any changes you're making, and then replace the contents of the old templates with the new templates when you're ready to make the switch. The content of resources stays the same, while everything in the template changes.

                    If you're just changing the content, do it live.

                    The only time I actually work on a dev server is when I'm building or testing components - and then I make sure the component works in dev, pack it into a package, and use package management to install it live. The reason for doing this on a dev server is that you're actually messing with the structure of the database, which you don't want to do on a live site (unless you make a backup of the database immediately before you do it, such as when you're installing MIGXdb). [ed. note: esnyder last edited this post 13 years, 8 months ago.]