sybase 备份数据脚本,备份出来的数据很小
2007-03-07 15:30
375 查看
首先导出数据库中的表,为导出数据做准备
互为参考
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
编辑导出的表
vi tables.tmp </dev/null
:1,2 d (删首两行)
:$ (到末行)
:-2,. d (删末三行)
:1,$ <<< (清各行左侧空格,即各行顶左。当然一个 < 也够用,1,$ 也可换成 % )
: x
开始导出数据
total=`cat tables.tmp|wc -l`
current=0
for table in `cat tables.tmp`
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp cqweb..$table out $table.bcp -Usa -Pcqpass -SMAW_WEB -Jiso_1 -c
echo "*** $table done ***n"
done
vi做成文件 然后改成可执行文件
sybase@MAW_WEB:/sybase/OCS-12_5/bin> chmod 775 dbbackup
参考原文如下:
2)将 pas 改为你的 sa 口令。
3)将 server 改为你的 SQL server 名。
4)要导入,将 out 改为 in 即可。
最后提醒你,别忘了要在 sybase 用户下创建一个目录,
把 bcpoutdata 置入其中,再运行。
什麽?你要打包、压缩。
哈,在后面加几条:
tar cvf data.tar *.bcp
compress data.tar
rm *.bcp
愿各位好运
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
vi tables.tmp </dev/null
:1,2 d
:$ d
:1,$ <<<
: x
EOF
total=`cat tables.tmp|wc -l`
current=0
for table in `cat tables.tmp`
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp database_name..$table out $table.bcp -Usa -Ppas -Sserver -Jiso_1 -c
echo "*** $table done ***n"
done
rm tables.tmp
首先感谢诸位对此文的兴趣,现解释如下:
一、导出用户数据库中的表,将其置入文件 tables.tmp 中。
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
二、编辑 tables.tmp ,因 tables.tmp 中首两行和末三行,
是我们不要的东西。前次的有小小错,现更正如下:
vi tables.tmp </dev/null
:1,2 d (删首两行)
:$ (到末行)
:-2,. d (删末三行)
:1,$ <<< (清各行左侧空格,即各行顶左。当然一个 < 也够用,1,$ 也可换成 % )
: x
EOF
至如 <使它们不在屏上显示,哈哈、、、就用它了。
找本书看看,再在 SHELL 下,带 <键入上述脚本,你就会有收获的。EOF 可用其他字母,但前后必须一致。
三、导出用户数据库各表中的数据
total=`cat tables.tmp|wc -l` (总表数)
current=0 (当前的第 n 张表)
for table in `cat tables.tmp` (将文件 tables.tmp 中的表名依次赋给 table)
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp database_name..$table out $table.bcp -Usa -Ppas -Sserver -Jiso_1 -c
echo "*** $table done ***n"
done
rm tables.tmp
声明: 以下内容来自CU
可在 sybase 用户下创建,将其命名为 bcpoutdata 。
然后 chmod a+x bcpoutdata
在 sybase 用户下运行 bcpoutdata 即可。
注:
1)将 database_name 改为你的数据库名。
互为参考
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
编辑导出的表
vi tables.tmp </dev/null
:1,2 d (删首两行)
:$ (到末行)
:-2,. d (删末三行)
:1,$ <<< (清各行左侧空格,即各行顶左。当然一个 < 也够用,1,$ 也可换成 % )
: x
开始导出数据
total=`cat tables.tmp|wc -l`
current=0
for table in `cat tables.tmp`
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp cqweb..$table out $table.bcp -Usa -Pcqpass -SMAW_WEB -Jiso_1 -c
echo "*** $table done ***n"
done
vi做成文件 然后改成可执行文件
sybase@MAW_WEB:/sybase/OCS-12_5/bin> chmod 775 dbbackup
参考原文如下:
2)将 pas 改为你的 sa 口令。
3)将 server 改为你的 SQL server 名。
4)要导入,将 out 改为 in 即可。
最后提醒你,别忘了要在 sybase 用户下创建一个目录,
把 bcpoutdata 置入其中,再运行。
什麽?你要打包、压缩。
哈,在后面加几条:
tar cvf data.tar *.bcp
compress data.tar
rm *.bcp
愿各位好运
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
vi tables.tmp </dev/null
:1,2 d
:$ d
:1,$ <<<
: x
EOF
total=`cat tables.tmp|wc -l`
current=0
for table in `cat tables.tmp`
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp database_name..$table out $table.bcp -Usa -Ppas -Sserver -Jiso_1 -c
echo "*** $table done ***n"
done
rm tables.tmp
首先感谢诸位对此文的兴趣,现解释如下:
一、导出用户数据库中的表,将其置入文件 tables.tmp 中。
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
二、编辑 tables.tmp ,因 tables.tmp 中首两行和末三行,
是我们不要的东西。前次的有小小错,现更正如下:
vi tables.tmp </dev/null
:1,2 d (删首两行)
:$ (到末行)
:-2,. d (删末三行)
:1,$ <<< (清各行左侧空格,即各行顶左。当然一个 < 也够用,1,$ 也可换成 % )
: x
EOF
至如 <使它们不在屏上显示,哈哈、、、就用它了。
找本书看看,再在 SHELL 下,带 <键入上述脚本,你就会有收获的。EOF 可用其他字母,但前后必须一致。
三、导出用户数据库各表中的数据
total=`cat tables.tmp|wc -l` (总表数)
current=0 (当前的第 n 张表)
for table in `cat tables.tmp` (将文件 tables.tmp 中的表名依次赋给 table)
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp database_name..$table out $table.bcp -Usa -Ppas -Sserver -Jiso_1 -c
echo "*** $table done ***n"
done
rm tables.tmp
声明: 以下内容来自CU
可在 sybase 用户下创建,将其命名为 bcpoutdata 。
然后 chmod a+x bcpoutdata
在 sybase 用户下运行 bcpoutdata 即可。
注:
1)将 database_name 改为你的数据库名。
相关文章推荐
- Shell脚本实现sybase数据备份
- 编写shell脚本将VPS上的数据备份到Dropbox网盘的方法
- Rmantool如何设置备份完成后将备份数据FTP出来?
- shell脚本实现系统监视统计与数据备份
- 程序猿(媛)Shell脚本必备技能之一: 在Linux下如何自动备份mysql数据
- Linux 平台下 Oracle 数据泵备份(expdp) SHELL 脚本
- Linux下通过FTP脚本自动备份数据到windows系统
- Linux环境下用exp备份Oracle数据表并导入的脚本
- 备份数据(文件)脚本
- Vbs备份数据脚本集合
- MySQL远程和本机备份数据脚本示例
- ORACLE 10G的数据泵自动备份脚本
- 每日备份数据的脚本
- windows下备份Mysql数据的脚本
- 写LINUX shell脚本 自动备份ORACLE用户下的表 保留30天数据
- Sybase 大数据切分备份和恢复
- 修改Navicat 默认sql脚本,数据,备份数据的放位置
- 脚本-每3天对数据库目录/var/lib/mysql做物理备份 把数据备份到系统/opt/dbbak目录
- debian8.4中mariadb数据备份脚本
- 日志/数据自动压缩备份删除小脚本