备份

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值