lovejuan1314 发表于 2013-1-30 01:40:56

写了一个备份Postgresql数据文件的超简单Linux Shell

#!/bin/bash#author:lovejuan1314#date:2008-12-19#This script will dump servers's views data per month###Define a array to store all of table names which will be backuped to herearray=(`psql --quiet --tuples-only-h server_name -p 5432 -U slony db_name -c "SELECT tablenameFROM pg_tables WHERE tablename like 'fb_fy_views_%';"`)#Array 's lengthlen=${#array[ * ]} echo "The array has $len members. They are:"i=0while [ $i -lt $len ]; do      echo "$i: ${array[$i]}"      #dumptable      pg_dump -t ${array[$i]}-i -O-h server_name -p 5432 -U slony -f "${array[$i]}.pgdump" -F c -Z 9 db_name      let i++donetar czvf .tar.gz *.pgdumprm -rf *.pgdump
页: [1]
查看完整版本: 写了一个备份Postgresql数据文件的超简单Linux Shell