Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other How to resolve database syncing when deploying with Git?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38431
    MarkMoran
    Member

    So, I’m just about to jump on the git bandwagon, but one thing is making me hesitate …

    First, I think my workflow will probably be similar to the one Chris described in his Screencast. I’ll deploy locally using MAMP and Coda2 with Git version control. Then I’ll deploy to a server where the site is live. Sounds like heaven.

    However, how do I resolve the issue of my local database eventually being out of sync with the database on the server? When I get comments, for example, on a wordpress installation, how do i resolve that automatically with my local version of the database/site without having to manually re-download the database every few days or a week?

    Any sort of git database version control system out there? (Or .. y’know … something else that might work?)

    Thanks in advance for your help!

    – Mark

    #104166
    MarkMoran
    Member

    Aw shucks … no comments …

    Well, I had a follow up questions so I’ll post it anyway.

    I have a multi-site installation on my server that I use to maintain my network of blogs. I use subdomains on the server, but I know that you can’t use subdomains on a local multi-site environment.

    I assume that I could just deploy the repository sans the config.php file to make sure that the subdirectory MS install doesn’t overlay the subdomain MS install, but I just want to confirm that this makes sense?

    Of course, I still haven’t figured out how to get around my database syncing issues. I really don’t want to keep downloading a new copy of the database every other day. Especially on sites with a lot of comments and discussions going on…

    Thanks!

    – Mark

    #106480
    khommon
    Participant

    If you simply need to change siteurl and home paths then this seems to be an elegant wp-config.php addition:

    if ($_SERVER == 'localhost:7000') {
        update_option('siteurl', 'http://localhost:7000' );
        update_option('home', 'http://localhost:7000' );
    } elseif (get_bloginfo('url') !== 'http://domain.com') {
        update_option('siteurl', 'http://domain.com' );
        update_option('home', 'http://domain.com' );
    }

    the above could be combined with the following to switch between different db credentials:

    if ($_SERVER[‘HTTP_HOST’] == ‘domain.com’) {
    define(‘DB_NAME’, ‘dbnamelive’);
    define(‘DB_USER’, ‘loginlive’);
    define(‘DB_PASSWORD’, ‘passlive’);
    } elseif ($_SERVER[‘HTTP_HOST’] == ‘staging.domain.com’) {
    define(‘DB_NAME’, ‘dbnamestaging’);
    define(‘DB_USER’, ‘loginstaging’);
    define(‘DB_PASSWORD’, ‘passstaging’);
    } else { //Catch all assumes you’re using DEV
    define(‘DB_NAME’, ‘dbnamelive’);
    define(‘DB_USER’, ‘loginlive’);
    define(‘DB_PASSWORD’, ‘passlive’);
    }

    If you also have ssh access to your server you could give a spin to this PHP CLI script to keep the dbs in sync:
    http://leehblue.com/sync-local-and-remote-database

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Other’ is closed to new topics and replies.