Home | Mirror | Search

4. Backup / Restore

Backup

pg_dump -i -h localhost -p 5432 -U user -Fc -c -f "your_db.backup" your_db
		

Restore

pg_restore -i -h localhost -p 5432 -U user -d your_db -v -c -Fc "your_db.backup"
		

local -> remote

set PG_HOME="C:\Program Files\PostgreSQL\8.1\bin"
%PG_HOME%\pg_dump.exe -i -h localhost -p 5432 -U woodart -Fc -c -f "woodart.backup" woodart
%PG_HOME%\pg_restore.exe -i -h woodart.8800.org -p 5432 -U woodart -d woodart -v -c -Fc "woodart.backup"
		

4.1. import

導入

\i file.backup
			
postgres=# \i /home/neo/woodart.backup
			
			

4.2. 大型資料庫

split 命令可以將大型檔案切成小塊以適應檔案系統限制的單個檔案大小。

分割,每650M為一個檔案,試用於光盤備份

			
$ pg_dump dbname | split -b 650m - filename
			
			

合併,並且恢復到資料庫中。

			
$ createdb dbname
$ cat filename* | psql dbname
			
			
comments powered by Disqus