Here are the actual scripts that were once used to sync corz.org and my mac dev mirror, using only my mac. my friendly local linux box was offline for a few days (hardware), so I needed a mac-only version, and then I realised how poor the OS X version of cp is. This one uses tar to do the backup, and create the log. I couldn't survive even a couple of days without my sync script..
Why? well, I don't have to keep tabs on which files I've edited, for starters; and I tend to edit lots of different site files in one session; keeping track would be an enormous task; the backup script does this for me. Only new and changed files are backed up, thereby indicating which files are new or changed!
The first time you run this script, it creates a new tar archive of your entire site. this will take a few moments and used as your baseline mirror, after which we can really use the script. Now, whenever you run the it, you will have only the updated files in the output log.
The few seconds it takes to edit your prefs here will save you hours and hours and hours in the future. Mac users Note: If your local site folder has custom icons, the resultant tar and tar.gz archives will probably be unusable on a PC, possibly other platforms. Yeah, it's a resource fork thing.
okay, here goes..
#!/bin/sh # corz.org mirror backup script (single-mac version).. # an interactive version is also included in the zip archive # note: this script is still very immature. # please report any bugs/problems. ta # prefs.. devroot="/Volumes/mac/webserv" sitefolder="cor" backupdir="/Users/corz/bax" arcname="corz" # this is the file who's content we will convert into ftp commands logfile="/Volumes/mac/webserver/itest/mirror.log" # end prefs cd $devroot echo >> $logfile echo "corz backup script: "`date "+%Y.%m.%d-%H.%M"`.. >> $logfile echo "corz backup script - "`date "+%Y.%m.%d-%H.%M"`.. if ! [ -e $backupdir/$arcname.tar ];then echo "creating initial 'base' archive.." echo "creating archive (base - no logging for this) .." >> $logfile tar --verify -cSf $backupdir/$arcname.tar $sitefolder > /dev/null fi echo "syncing backup archive.." echo "creating archive (sync) .." >> $logfile echo >> $logfile tar -uvSf $backupdir/$arcname.tar $sitefolder >> $logfile echo "gzipping backup archive.." echo "creating archive (gzipping) .." >> $logfile gzip -c9 $backupdir/$arcname.tar > $backupdir/`date "+%Y.%m.%d-%H.%M"`_$arcname.org.tar.gz echo "backup script completes .." >> $logfile echo >> $logfile echo "corz backup script completed" exit 0 # fin
The output from the converter would go into a script something like this..
(after a quick manual check, of course)
#!/bin/sh # upload new files to website.. HOST='ftp.mysite.com' USER='username' PASSWD='password' ftp -n $HOST <<FTP_QUIT quote USER $USER quote PASS $PASSWD binary # paste converted ftp commands right here quit FTP_QUIT exit 0 # fin
That's it! your wesite and its mirror are one!
Welcome to corz.org!
I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!