备份

by camry.wu

备份文字

源程序备份当然是要用 cvs 等版本控制工具, 不过有些不往 cvs 上放的程序或者文章等东西就要自己备份喽. 基本思路是先把东西打包, 然后发送到自己的邮箱里. (当然首先要申请个大点的邮箱, 比如说 gmail.) 用 ant 只不过是批处理一下方便点.

要用 ant 发送邮件, 得到 sun 下载 mail.jar, jsse.jar, activation.jar 先. 然后放到 ant 的 lib 中去.

build.xml 脚本如下:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 camry.wu@gmail.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<project name="backup-src" basedir="." default="backup">
<!-- xxx project -->
<property name="project.proj" value="/home/camry/work/xxx/proj"/>

<property name="dist.lib" value="dist/lib"/>

<property name="backup.dir" value="backup"/>

<target name="init">
<buildnumber/>
<mkdir dir="${backup.dir}"/>
</target>

<!-- 压缩打包 -->
<target name="zip" depends="init" description="zip">
<!-- 关于这个部分可见使用 ant 的文章 -->
<ant dir="${project.proj}" target="src-zip"/>
<!-- 继续打包其他程序, 文章等... -->
</target>

<!-- 合并 -->
<target name="merge" depends="zip" description="merge">
<mkdir dir="${backup.dir}/tmp"/>
<!-- 东西都拷贝进来 -->
<copy todir="${backup.dir}/tmp" preservelastmodified="true">
<fileset dir="${project.proj}/${dist.lib}">
<filename name="*.zip"/>
</fileset>
</copy>
<zip basedir="."
destfile="${backup.dir}/src-backup-${build.number}.zip"
whenempty="fail">
<include name="${backup.dir}/tmp/*.zip"/>
</zip>
<delete dir="${backup.dir}/tmp"/>
</target>

<!-- 发送邮件 -->
<target name="email" depends="init" description="email">
<!--
我在这里出点问题, 得找个 smtp 才能发送邮件
要加上 smtp, 可以在 mail 标签中添加:
mailhost="smtp.provider.com" mailport="25"
-->
<mail subject="src-backup-${build.number}" charset="utf-8">
<from address="camry.wu@gmail.com"/>
<to address="camry.wu@gmail.com"/>
<message>
src backup.
author: camry.wu
backup number: ${build.number}
</message>
<fileset dir="${backup.dir}">
<filename name="src-backup-${build.number}.zip"/>
</fileset>
</mail>
</target>

<!-- 备份 -->
<target name="backup" depends="merge, email" description="backup">
</target>
</project>

往后想起来了就去备份一下吧, 当然也可以写个脚本定时备份:)

最后更新: 2005年5月10日 星期二 21点21分36秒
HTML 转换程序: TeX2page 2004-09-11
阅读更多
个人分类: java 开源工具
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭