Archive

Archive for December, 2007

svn 版本库的备份和还原

December 20th, 2007

仓库中版本的备份及还原形式主要有两种:
方式一:直接备份仓库整个文件夹(全部版本),重装svn程序后直接还原过去。

方式二:通过svn命令行备份和还原指定版本号的数据
全备份:使用svnadmin hotcopy或svnsync来做,例:
svnadmin hotcopy path/to/repository path/to/backup –clean-logs

增量备份:使用svnadmin dump的–incremental选项来实现
svnadmin dump 版本库路径及名称 –revision 上次导出的版本号:到本次要导出到的版本号 –incremental > 导出的命名

还原版本:svnadmin load 要恢复的版本库路径及名称 < 导出的命名

svnadmin hotcopy path/to/repository path/to/backup –clean-logs

一个技巧:

如果你有一个较大的Subsersion版本库而你又想用最少的空间来将它备份下来,用这个命令(请将/repo替换成你的版本库路径)吧:

svnadmin dump –deltas /repo |bzip2 |tee dump.bz2 | md5sum >dump.md5

分步解释:
最重要的一步是 -deltas,将消耗更多的CPU资源,但拥有更有效的差异存储办法。

bzip2压缩方案比gzip慢,但换来的更好的压缩率。
更有趣的是,tee方法将压缩的数据流转向到文件dump.bz2,同时将其输出到标准输出,后者有转向给了MD5摘要计算工具。

要恢复这个版本库,检查校验值(md5sum创建的),创建一个空的版本库,恢复备份:

md5sum -c dump.md5 <dump.bz2
svnadmin create newrepo
bzcat dump.bz2 | svnadmin load newrepo

请享受压缩后用MD5校验的备份吧,最后别忘记将dump.md5和dump.bz2存储到真正安全的地方!

webflier i.t.

terminal上执行的 python 程序如何能在关闭终端时继续执行?

December 12th, 2007

python /home/neil/www/test/manage.py runserver 0.0.0.0:8888 &
& 加在命令的最后

但是只加&是不够的,终端退出时会向所有进程发SIGHUP信号
这样可以
nohup python … &

webflier i.t.

[How-To]Ubuntu apt-get behind ISA Server with NT Authenticfation required

December 12th, 2007

在公司里面,网络访问都是通过ISA Server的(Microsoft® Internet Security and Acceleration Server),在使用Windows的时候不会出现任何问题,可是前两天装了Ubuntu Linux,遇到了些问题。

我使用firefox访问网络没有问题,只需要设好代理服务器地址,浏览网站时输入相应的用户名和密码即可,但在console下面使用apt-get更新系统时有问题。

开始我觉得应该这样设置代理:
export http_proxy=http://domaindomainuser:password@proxy.corpnet.com:8080

可是总会出现这个错误:
407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. )

后来在网上搜索了一下,找到方法解决这个问题了:

Download ntlmaps-0.9.9.0.1 from here

$ tar -zxvf ntlmaps-0.9.9.0.1

$ vim ntlmaps-0.9.9.0.1/server.cfg

Edit PARENT_PROXY,PARENT_PROXY_PORT,USER,PASSWORD to match your preferences, then run main.py

$ ./ntlmaps-0.9.9.0.1/main.py &

$ export http_proxy=”http://127.0.0.1:5865

$ sudo apt-get update

Now, everything is OK.

reference: http://www.lupaworld.com/912/viewspace_2210.html

webflier i.t.

在 Rails 之外使用 ActiveRecord

December 12th, 2007

原文链接已经被墙:http://lightyror.thegiive.net/2007/03/rails-activerecord_15.html

今天要写一个cron script 要用到数据库,因为已经被Active Record 惯坏了,懒得用SQL。所以就花点时间Survey 怎么再Rails 之外使用Active Record


简单版

1. require
相关的lib

require “rubygems”
require “active_record”

2.
建立DB Connection

ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:username => “root”,
:host => “localhost”,
:password => “secret”,
:database => “plants_db”
)

3.
宣告ActiveRecord Class

class MyClass < ActiveRecord::Base
end


如此就可以开始使用啦。不过如果遇到你必须一次操作多个DB 的情况时,你可以用比较Rails 一点的Config 来写作

加入Config 的用法

1. require
相关的lib

require “rubygems”
require “active_record”

2.
撰写DB 配置文件,我们仿Rails 写一个database.yml

development:
__adapter: mysql
__host: localhost
__username: root
__password:
__database: lala



3.
将配置文件读进来,读到一个$config 变数

$config = YAML.load_file(File.join(File.dirname(__FILE__), ‘database.yml’))

4.
宣告ActiveRecord 对象,记得加上establish_connection

class MyClass < ActiveRecord::Base
establish_connection $config[''development"]
end


5.
开始快快乐乐使用ActiveRecord

webflier i.t.

Problem of starting a manually created postgres server in Ubuntu

December 2nd, 2007

You could chown the directory /var/run/postgresql/ to the user postgres is
running as. You might need root access for that as well, in case you dont
have it you could ask your sysadmin to do it.

Regards,
Patrick Lindeman

> I’m trying to start my postgres server and it gives me the following
> errror
>
> FATAL: could not create lock file
> “/var/run/postgresql/.s.PGSQL.5432.lock”:
> Permission denied
>
> Now obviously to touch the file that the error message is talking about,
> one
> needs root permission that the user account under which my postmaster is
> runnnig doesn’t have.
>
> Can anyone tell me the fix.
>
> Thanks
>

Powered by ScribeFire.

webflier i.t.