Managing Development and Production Directories Using rsync
In my project, I am having development and production directories in the same machine. I know having subversion and would be better, though I am still not quite comfortable with it. Anyway, they are messy, and have been messy for about a year.
Now I got tired of updating modified files by hand every time, and looked up a software that can handle my need. rsync seems like tiny little tool that I was looking for. I referred two website rsync man page and rsync examples, and let the rsync synchronizes my development and production directories, and backs up both of them in remote server in incremental manner.
So, here is the scheme. I have two directory; devel and www, which is development and production directories, respectively.
I’ve set aliases to do rsync from the development directory to the production directories, and from the production to the development directories.
alias rsync-devel=’rsync -Cavuzb –filter=’\”dir-merge www/.rsync-filter’\” www/ devel/’
alias rsync-devel-l=’rsync -Cavuzb -n –filter=’\”dir-merge www/.rsync-filter’\” www/ devel/’
alias rsync-www=’rsync -Cavuzb –filter=’\”dir-merge devel/.rsync-filter’\” devel/ www/’
alias rsync-www-l=’rsync -Cavuzb -n –filter=’\”dir-merge devel/.rsync-filter’\” devel/ www/’- -a : archives files, means preserve permission, owner, and etc.
- -v : verbose
- -u : update, don’t copy if file in destination is newer
- -z : compress
-C : cvs style exclusion, means excludes patterns below
CS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo ~ # .#* ,* _$* $ *.old *.bak *.BAK *.orig *.rej .del- *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/
- -b : leaves backup
- -n : displays list of files that will be updated (does not update)
This is my filter file. rsync filter
Between the production machine and the remote server, I’ve copied shell script from rsync example website and slightly modified to meet my needs. Since I wish I could back up
develandwwwdirectory independently, I would like to call the script asscript.sh develto back updeveldirectory,script.sh wwwto back upwwwdirectory. So here is the modification. remote rsync