InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Rsync tutorials

  • Linux rsync tutorial
  • Custom identity file with rsync
  • Exclude a file extension
  • Rsync - show progress and transfer rate
  • Using dryrun to list changed files
  • Using rsync for production release automation
 
  • Home
  • > Tutorials
  • > Linux/Unix Command Line
  • > Rsync

How to use rsync for production release automation

By admin | Last updated on Jan 26, 2016

Rsync can be used to automate the production releases for wordpress or any other site. I maintain two wordpress sites – one for development purpose and one for production. Both sites have their respective apache web server document root. I have used the convection devel_infoheap and prod_infoheap for the two blogs.

Here is a workflow which works nicely for me:

  1. Keep all your stuff (non wordpress) under version control.
  2. Create a push.sh bash script which take an argument “devel” or “prod”. You can keep any other ids for your develment and production sites.
  3. Keep this code in your sync push.sh script
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" pwd )"
    CONFIG=devel_
    if [ "$1" == "prod" ] ; then
      CONFIG=prod_
    fi
    
    #change it if you target machine is not same as the script machine
    HOST=localhost
    
    cd $DIR
    
    ## replace files/directories to sync and the target directory according to your configuration
    rsync -r -az ../ui/data ../ui/img $HOST:/var/www/${CONFIG}infoheap/
  4. You can add more files and directories to above script as and when needed.
  5. For pushing to devel blog site just run push.sh devel and for production just run push.sh prod. This make push process very streamlined.
  6. For files like robots.txt I maintain two versions (devel_robots.txt and prod_robots.txt). With above convection, it is easier to sync robots.txt also using the following code in bash script
    rsync -r -az ${CONFIG}robots.txt  $HOST:/var/www/${CONFIG}infoheap/robots.txt

    Note that since source and target file names are different here, we had to specify target file in rsync command.

Suggested posts:

  1. Custom terminal tab title and ssh on mac
  2. How to install drupal on Mac usin MAMP
  3. Mysql – how to copy a table
  4. Linux/Unix – find inode number of a file
  5. Java – array for-each loop
  6. SVG – beginner tutorial
  7. Find which process is listening on a port on Linux
  8. redis cli quick start tutorial
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Rsync, Tutorials, Wordpress
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress