I have a source directory that contains some file updates that I need to copy in to my web app dir. Before I copy the files into place I need to backup each original that is going to be over written to backup. I can't backup the whole web app to the backup location as that would be 00's of files. I need to keep the dir structure (no flattening) & all 3 locations have the same structure.
My curent idea is to do this in 2 phases. Backup then update. The update is trivial (copy & fileset). The backup is causing me the problems as I only want to backup the files that will be updated.
Below is my current iteration (which doesn't work)... Use a copy with todir as the backup location, then have a fileset that searches the source files so I have the set of changing files. What I obviously need to do is change the paths of the files returned by the fileset so that they reference the existing files rather than the new ones & that's where I'm stuck. Anyone know how to change the paths of files returned by fileset? I use pathconvert below which I know is wrong, but I left it in to show the conversion I'm after - anyone know how to do this?? Or a better way maybe!!
${backup.dir} --> root of file backup
${console.war} --> location of existing files - the top of the application dir
${update.dir} --> root of updated files
<copy todir="${backup.dir}/app/console.war">
<fileset dir="${update.dir}/app/console.war" includes="**" id="id.update.files"/>
<pathconvert refid="id.update.files" property="custom.file.target">
<map from="${update.dir}/app/console.war" to="${console.war}"/>
</pathconvert>
</copy>
exec
task to invoke rsync to do the backups before copying over updated files. If you adverse to using rsync, have a look at thesync
task for performing the backup before doing the update. – ewh