19 July, 2007

HowTo backup Java project

This topic may be helpful for Java developers, who use Ant and want to backup their Java projects (especially for developers, who don't use any of Version Control Systems like CVS, SVN, etc.).

I've created simple Ant script for backup purposes. This script creates archive with unique (time depended) name.

E.g.: If project (project's folder) has name "Eclipsoid", it will be packed to "Eclipsoid-2007.07.19_11.52.00.tar.bz2" archived file.

You may insert "ubackup" target into your project's build.xml file or use this script standalone.


<project default="ubackup" basedir=".">
<target name="ubackup">
<format property="backuptime" pattern="yyyy.MM.dd_HH.mm.ss"/>
<basename property="currentdir" file="."/>
<property name="backupfilename" value="${currentdir}-${backuptime}"/>
<tar destfile="../${backupfilename}.tar.bz2" compression="bzip2" basedir="../${currentdir}"/>

No comments: