brettbrewer.com

Programming + Design

Home arrow Tips & Tricks arrow X-Cart Hacking arrow Copying development xcart site to live site
Copying development xcart site to live site PDF Print E-mail
Written by Administrator   
Friday, 18 December 2009

In my xcart development travels I often have the need to go live with a copy of my development site, usually by copying most, but not all of the files from the development xcart directory to the live xcart directory on a dedicated linux server. Usually there's already a version of xcart in the live directory and I just need to copy changed files to the live version. Here's a simple shell script which uses rsync to do just that. You can just copy this into a shell script such as "sync_my_site.sh" and then run it as a user that has permissions to write to both directories. Just set your sourcedir and targetdir accordingly.

sourcedir=/path/to/my/dev/site/docroot/*
targetdir=/path/to/my/live/site/docroot

rsync --verbose --recursive --progress --times --perms --links \
--exclude ".svn" --exclude "config.php" --exclude "*.bak" \
--exclude "var" --exclude ".htaccess" \
$sourcedir \
$targetdir

This will copy all the files in sourcedir to targetdir except for the .htaccess, config.php, .svn folders and var folder.  Note the asterisk on the end of the sourcedir. You'll want to keep that there or you'll end up with a copy of the sourcedir directory inside the target directory which is probably not what you want. The backslashes at the ends of the lines are necessarry -- they are there to let the rsync command span multiple lines. You could put the rsync command all on one line, but if you are using a text editor like nano and don't turn off automatic line breaks it could break the script. Also it's just easier to read if you break it into multiple lines.

 

Last Updated ( Friday, 18 December 2009 )
 
Next >
© 2010 www.brettbrewer.com
Joomla! is Free Software released under the GNU/GPL License.