This is one of those “well, if I don't write it down, I'll forget it,” posts, but someone else may find it helpful as well.
I recently did a bunch of updates on my favorite website. I keep a duplicate copy of the site where I can work on it without making a big mess of the active site. All of the files are in a directory we'll call $HOME/website. So I'm going to modify the files in my local copy of $HOME/website, check to make sure I haven't frakked anything, and then upload everything to the hosting computer, pause, take a deep breath and pray I really haven't frakked anything, and update the real website.
So what I want to create is a tarball consisting of all the files I've changed in $HOME/website since the last time I did an update. This is an almost one-liner. I say that because you need to do one step before you make any changes at all:
$ touch $HOME/newupdates
This creates a zero-length file. The important thing is that it will be older than any of the files you are about to change, and younger than any of the files that remain unchanged. If you have another file like this around, then you don't need this step.
Now make all the changes you want, making sure you have valid spelling, HTML, physics, tax advice, etc.
Now do the archive:
cd $HOME ; tar cvzf updates.tar.gz \ `find $HOME/website -type f -newer newupdates \ | xargs`; touch newupdates
(That's really all one line, of course, though you should be able to enter it as is with the backslashes.)
This uses the find command to list all regular (-type f) files in the directory $HOME/website which are newer than newupdates, then uses xargs to put them into a single string, and creates a gzipped tarball file named updates.tar.gz. Then it again touches the newupdates file, so that the next time you do this you won't pick up the files you've already archived.
Then copy updates.tar.gz wherever you want it.
0 comments:
Post a Comment