⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pg_upgrade

📁 关系型数据库 Postgresql 6.5.2
💻
字号:
#!/bin/sh## pg_upgrade: update a database without needing a full dump/reload cycle# CAUTION: read the manual page before trying to use this!echo "pg_upgrade is disabled in this release because the on-disk structure" 1>&2echo "of the tables has changed compared to previous releases." 1>&2exit 1trap "rm -f /tmp/$$" 0 1 2 3 15if [ "$#" -eq 0 ]then	echo "Usage:  $0 [-f inputfile] old_data_dir" 1>&2	exit 1fiif [ "X$1" = "X-f" ]then	INPUT="$2"	shift 2	if [ ! -f "$INPUT" ]	then	echo "$INPUT does not exist" 1>&2		exit 1	fielse	INPUT=""fiif [ "$#" -ne 1 ]then	echo "Usage:  $0 [-f inputfile] old_data_dir" 1>&2	exit 1fiOLDDIR="$1"# check thingsif [ ! -f "./data/PG_VERSION" ]then	echo "`basename $0` must be run from the directory containingthe database directory \`data' (`dirname $PGDATA`.)" 1>&2	exit 1fiif [ ! -d "./$OLDDIR" ]then	echo "You must rename your old /data directory to /$OLDDIR and run initdb." 1>&2	exit 1fiif [ ! -d "./$OLDDIR/base/template1" ]then	echo "There is not database template1 in ./$OLDDIR/base." 1>&2	exit 1fiif [ ! -d "./data" ]then	echo "You must run initdb to create the template1 database." 1>&2	exit 1fiif [ ! -d "./data/base/template1" ]then	echo "$0 must be run as the postgres superuser." 1>&2	exit 1fi# do I need to create a database?# remove any COPY statements# we don't even need pgdump_oid because we are moving pg_variable# then shouldn't be in there anywaycat $INPUT | awk '	{				if (toupper($1) == "COPY" && $2 != "pg_shadow")					while (getline $0 > 0 && $0 != "\\.")						;				else	print $0;			}' >/tmp/$$ #create empty tables/indexespsql "template1" <"/tmp/$$"if [ $? -ne 0 ]then	echo "There were errors in the input script $INPUT.$0 aborted." 1>&2	exit 1fifor DIR in data/base/*do	BASEDIR="`basename $DIR`"	if [ -d "$DIR" -a \	     -d "$OLDDIR/base/$BASEDIR" -a \( "$BASEDIR" != "template1" \) ]	then	for FILE in $OLDDIR/base/$BASEDIR/*		do			BASEFILE="`basename $FILE`"			if [ `expr "$BASEFILE" : "pg_"` -ne 3 -a \				"$BASEFILE" != "PG_VERSION" ]			then	mv $FILE $DIR			fi		done	fidonemv $OLDDIR/pg_log datamv $OLDDIR/pg_variable dataecho "You may remove the $OLDDIR directory with 'rm -r $OLDDIR'."

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -