Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6535049
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类:

2009-01-11 22:33:26

前提是已经熟悉PostGreSQL的命令
1:bkpg.sh的内容:
#!/bin/bash
/usr/local/pgsql/bin/pg_dump -hlocalhost -p5431 -Ugroupware hitware>/data/back/hitware/`date +%Y-%m-%d-%T`.sql
/usr/local/pgsql/bin/pg_dump -hlocalhost -p5431 -Ugroupware stemsoft>/data/back/stemsoft/`date +%Y-%m-%d-%T`.sql
2:backpg.sh的内容:
#!/usr/bin/expect
#Description:The Scrpit is auto backup the postgresql database at 8:00 PM       #            every day
#Author:wang.changchun@stemsoft
#Date:2008-12-10
set passwd "12345678"
spawn ~/bin/bkpg.sh;
expect "*Password:";
sleep 0.1;
send "$passwd\r";
expect "*Password:";
sleep 0.1;
send "$passwd\r";
#等待60秒(1分钟);如果不等待,只生成文件,而导出动作没有时间执行。
sleep 60;
#back hitware
#spawn "/usr/local/pgsql/bin/pg_dump -h localhost -p 5431 -U groupware hitware > /data/back/`date +%Y-%m-%d-%T`.sql [lindex $argv 0]";
#expect "*Password:";
#sleep 1;
#send "$passwd\r";
把上面的两个文件存到PostGreSQL用户的bin目录下,赋予执行权限。
然后用crontab -e添加到用户的定时任务就可以了。
阅读(5869) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~