Jump to content

Shared staging & production databases


leftblank
 Share

Recommended Posts

Hi,

Is there any problem with having staging and production sites sharing the same database? If content is updated in the shared database, then I'd know that the two system's content were in sync with each other, and code changes in files would be the only difference between the two. And I'd just keep new content unpublished or hidden until it was due to go live. Could anyone let me know what the would be the benefit of separate staging and production databases?

Cheers!

Link to comment
Share on other sites

I'm using rsync to keep development and production sites ~in sync

I have two separate commands to pull assets from server and then finally pushing the whole site directory back in, excluding some files/dirs if needed.

It's not beautiful, but it works.. for now  : )

Link to comment
Share on other sites

My solution for the issues mentioned by @diogo above is a simple script that syncs (via rsync) contents of /site/assets/files/ between dev and production sites ("two-way sync"), but that's just about it. Not a perfect solution, but works mostly just fine.

Certain things (such as modules cache) still need to be cleared on a per-environment basis when making changes there (adding modules etc.) I wouldn't worry about logs, sessions or cache files -- it's actually better that they're environment-specific -- which leaves "files" only thing you'll need to keep in sync.

One drawback is the situation where you have assets in both versions and then remove them via admin UI from one version; those assets will stay in other version of the site and you'll have to figure out a way to remove them from there too. This thread provides some helpful code samples for doing exactly that and you could also create a simple module that triggers one-way sync operation (rsync, for an example, has the ability to remove extra files from target directory) every time an asset is removed.

If anyone has a better solution in place, I'd be happy to hear about it. I've been considering various options starting from shared directories, but haven't found anything solid yet (it'd be easier if both sites lived on same server, but generally dev environment shouldn't exist on same server as production one IMHO..) :)

  • Like 1
Link to comment
Share on other sites

rsync can also be used with the --delete option, which will synchronize deletions as well. 

rsync --archive --rsh=/usr/bin/ssh  --verbose --delete account@domain.com:www/site/assets/files/* /path/to/domain.com/site/assets/files/
Link to comment
Share on other sites

  • 3 years later...

I'm using mod_rewrite to link to files on the live system if they are not found on the development systems:

# file: .htaccess
<IfModule mod_rewrite.c>
	RewriteEngine On

	# Get all asset files from remote if localy not available
	RewriteCond %{REQUEST_FILENAME} !-f [NC]
	RewriteCond %{REQUEST_URI} ^/www/site/assets/files/
	RewriteRule ^(.*)$ https://www.live.com/$1 [L]
</IfModule>

 

 

  • Like 4
Link to comment
Share on other sites

17 hours ago, dragan said:

wp-content? :o

Wooohaaa, caught me! Used this on an wp installation previously but the technique should work on PW as well… You should be happy that I moved on from wp – and even more happy that I learned ONE thing I can use for PW ;)

Not looking back to wp a single second.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...