I need some analog of rsync
for ant. The issue is to copy files from source directory to the set of subdirectories that was previously accomplished with script
rsync -r --ignore-existing $BASE_DIR/common/config/* $BASE_DIR/config
Thanks for any help
So if you are running this sort of command frequently, and the set of changed files is small relative to the total number of files, you should find that rsync is faster than cp.
Rsync, which stands for remote sync, is a remote and local file synchronization tool. It uses an algorithm to minimize the amount of data copied by only moving the portions of files that have changed.
The rsync tool can recursively navigate a directory structure and update a second location with any new/changed/removed files. It checks to see if files exist in the destination before sending them, saving bandwidth and time for everything it skips.
Another way to save network bandwidth and speed up transfers is to use compression, by adding -z as a command line option.
You can use exec to call rsync from Ant, you could use the java task to call Jarsync or java-sync or you could create a custom ant task to call either of those libraries.
Zombie question but posting https://gist.github.com/garethr/878364 in case I ever search for it myself again. Pasting Gist content in case something something.
<project name="{{ name }}" default="help" basedir=".">
<property name="username" value="{{ username }}"/>
<property name="host" value="{{ host }}"/>
<property name="dir" value="/srv/{{ path }}/"/>
<tstamp>
<format property="TODAY_UK" pattern="yyyyMMddhhmmss" locale="en,UK"/>
</tstamp>
<target name="help" description="show available commands" >
<exec executable="ant" dir="." failonerror="true">
<arg value="-p"/>
</exec>
</target>
<target name="deploy-to" description="show where we are deploying to" >
<echo>${username}@${host}:${dir}</echo>
</target>
<target name="deploy" description="deploy usng rsync" >
<exec executable="rsync" dir="." failonerror="true">
<arg value="-r"/>
<arg value="."/>
<arg value="${username}@${host}:${dir}"/>
<arg value="--exclude-from=rsync.excludes"/>
<arg value="-v"/>
</exec>
</target>
<target name="deploy-test" description="test deploy usng rsync with the dry run flag set" >
<exec executable="rsync" dir="." failonerror="true">
<arg value="-r"/>
<arg value="."/>
<arg value="${username}@${host}:${dir}"/>
<arg value="--exclude-from=rsync.excludes"/>
<arg value="--dry-run"/>
<arg value="-v"/>
</exec>
</target>
<target name="backup" description="backup site" >
<exec executable="scp" dir="." failonerror="true">
<arg value="-r"/>
<arg value="${username}@${host}:${dir}"/>
<arg value="backups/${TODAY_UK}"/>
</exec>
</target>
</project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With