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

    (Revo 2.0.0pl)
    I’d like to write a script to deploy from a developpement site to a production site knowing that both where manually installed first. The differences between the two versions are: not the same users and a few different system settings (there’s no user comments and contributors edit dev site). I’d like to know if the following method looks good:

    1. I backup my dev db without the following tables:
    - event_logs - managers_logs - member_groups
    - register_message - session - users
    - user_attributes - user_messages - user_settings
    - system_settings (except a predefined ignore list of settings not to change)

    2. I commit the dev project files ignoring the following files and directories:
    - core/config
    - core/cache
    - all .htaccess

    3. I update the production site and its the database

    Will it work? I know that any time I’ll add a new package that stores the user ids I’ll have to do a special update of the production site but it’s better than developping on the production server, isn’t it?
    Another solution would be to save the user related table on the production db and merge then back after the update? What about it?
    What are the following db table for: keyword_xref, register_queues, register_topics?

    I was unable to find same clear answers about deploying a Revo site, so I hope someone will be able to help me on that and that it will help others.

    Thank you,

    Thierry.

      • 29861
      • 59 Posts
      Just in case it helps someone. I’m not sure it’s a correct solution but it seems to be working.
      I made a makefile to operate the deploy. Here’s the part about MODx deploy (Note: I didn’t copy all the variables initialization that are context dependant):

      ...
      CONFIGFILES=core/config/config.inc.php index.html
      CHMOD777=core/cache/
      DBTABLEIGNORE=modx_event_logs modx_member_groups modx_register_messages modx_session modx_users modx_user_attributes modx_messages
      DBTABLEIGNOREARG=`for i in $(DBTABLEIGNORE); do printf -- "--ignore-table=$(DEVDBNAME).$${i} "; done;`
      ...
      # DEPLOY
      deploy:
      
      ######### SVN COMMIT PART ###########
      # Commit only if COMMIT variable (the commit message) is defined
      ifneq ("$(COMMIT)","")
      	# $(MSG_PREFIX) $(COMMIT)
      
      	# Save dev to prod db transfert script (ignoring tables DBTABLEIGNOREARG)
      	mysqldump --single-transaction -u $(DBUSER) --password=$(DBPASS) $(DEVDBNAME) $(DBTABLEIGNOREARG) | gzip -9 > $(ACTIVECONFDIR)$(DATE)-$(DEVDBNAME).sql.gz
      
      	# Set svn ignore
      	svn propset svn:ignore -F $(DEVDIR)/svnignore.txt $(DEVDIR)
      	$(foreach dir,$(SVNIGNOREDIRECTORIES),svn -R propset svn:ignore "*" $(DEVDIR)$(dir);)
      
      	# Add and commit
      	svn add $(DEVDIR)* --force
      	svn commit -m "$(MSG_PREFIX) $(COMMIT)" $(DEVDIR)
      else
      	# $(NOCOMMITMSG)
      endif
      
      	######### PREPARE NEW DIRECTORY ###########
      
      	# Export SVN last version of the site 
      	svn export -q $(SVNREPO) $(PRODDIRNEW)
      
      	# Change mod for CHMOD777 files and directory in the new production site 
      	$(foreach file,$(CHMOD777),chmod -R 777 $(PRODDIRNEW)$(file);)
      	# Copy config files from old production site to new production site
      	$(foreach file,$(CONFIGFILES),cp $(PRODDIR)$(file) $(PRODDIRNEW)$(file);)
      	# TBD Here: delete unnecessary files and folders
      
      	######### SAVE PART ###########
      
      	# Make a zip of current production site
      	mkdir -p $(PRODSITESAVEDIR)
      	tar -cjf $(PRODSITESAVEDIR)$(DATE)-$(PROJECTNAME).tar.bz2 $(PRODDIR)
      
      	# TBD Here: Set both sites to "Offline"
      
      	# Save Production db, Development db and then the script to transfert the development db to the production db
      	mkdir -p $(PRODDBSAVEDIR)
      	mkdir -p $(DEVDBSAVEDIR)
      	mysqldump --single-transaction -u $(DBUSER) --password=$(DBPASS) $(PRODDBNAME) | gzip -9 > $(PRODDBSAVEDIR)$(DATE)-$(PRODDBNAME).sql.gz
      	mysqldump --single-transaction -u $(DBUSER) --password=$(DBPASS) $(DEVDBNAME) | gzip -9 > $(DEVDBSAVEDIR)$(DATE)-$(DEVDBNAME).sql.gz
      
      	# TBD Here: Set back development site to "Online"
      
      	######### DEPLOY PART ###########
      
      	# Import the dev to prod db tranfert script in production db
      	gunzip < $(ACTIVECONFDIR)`ls -1t $(ACTIVECONFDIR) | head -n 1` | mysql -u $(DBUSER) --password=$(DBPASS) $(PRODDBNAME)
      
      	# Move current production site to the production save folder and rename the new production site
      	mv $(PRODDIR) $(PRODSITESAVEDIR)
      	mv $(PRODDIRNEW) $(PRODDIR)
      
      	# TBD Here: Set back production site to "Online"
      
      


      I know it lacks explanations but I hope this isn’t an absurd method and that it can help someone.