Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any analog of rsync for Ant?

Tags:

rsync

ant

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

like image 707
Viktor Stolbin Avatar asked Jun 20 '12 09:06

Viktor Stolbin


People also ask

Is cp or rsync faster?

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.

What exactly does rsync do?

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.

Is rsync recursive?

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.

How do I speed up rsync?

Another way to save network bandwidth and speed up transfers is to use compression, by adding -z as a command line option.


2 Answers

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.

like image 179
Tom Howard Avatar answered Oct 21 '22 11:10

Tom Howard


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>
like image 7
moutons Avatar answered Oct 21 '22 10:10

moutons