postgresql使用pg_dump和pg_restore 实现跨服务器的数据库迁移或备份
因为业务需求,需要将服务器上的postgre多个数据库的数据整个库得迁移到另一个postgre数据库上。
-F format
--format=format
Selects the format of the output. format can be one of the following:
p
plain
Output a plain-text SQL script file (the default).
c
custom
Output a custom-format archive suitable for input into pg_restore. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.
d
directory
Output a directory-format archive suitable for input into pg_restore. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default.
t
tar
Output a tar-format archive suitable for input into pg_restore. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore. -C
--create
Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.
This option is only meaningful for the plain-text format. For the archive formats, you can specify the option when you call pg_restore.
-E encoding
--encoding=encoding
Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) -O
--no-owner
Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O.
This option is only meaningful for the plain-text format. For the archive formats, you can specify the option when you call pg_restore.
postgresql使用pg_dump和pg_restore 实现跨服务器的数据库迁移或备份的更多相关文章
- SQL Server跨服务器的数据库迁移
1. 使用sql server task中back up 任务,保存为*.bak 文件. 2. 在另一个server中restore database,如果已经存在这个database,会覆盖之前的数 ...
- SQLServer跨服务器访问数据库(openrowset/opendatasource/openquery)
SQLServer跨服务器访问数据库(openrowset/opendatasource/openquery) 1.启用Ad Hoc Distributed Queries 在使用openrowset ...
- SQL Server跨服务器操作数据库
今天给大家来分享一下跨服务器操作数据库,还是以SQL Server的管理工具(SSMS)为平台进行操作. 什么是跨服务器操作? 跨服务器操作就是可以在本地连接到远程服务器上的数据库,可以在对方的数据库 ...
- SQL跨服务器查询数据库
有时候一个项目需要用到两个数据库或多个数据库而且这些数据库在不同的服务器上时,就需要通过跨服务器查找数据 在A服务器的数据库a查询服务器B的数据库b 的bb表 假如服务器B的IP地址为:10.0.22 ...
- postgresql跨服务器复制数据库
假设名为dbname数据库需要从A服务器拷贝到B服务器 接收服务器B postgres用户 需先重置B服务器postgres系统用户的密码,使之与数据库用户postgres一致: passwd -d ...
- sqlserver 添加服务器链接 跨服务器访问数据库
转载地址1:https://www.cnblogs.com/wanshutao/p/4137994.html //创建服务器链接 转载地址2:https://www.cnblogs.com/xulel ...
- [转]SQLServer跨服务器访问数据库(openrowset/opendatasource/openquery)
正 文: 1.启用Ad Hoc Distributed Queries 在使用openrowset/opendatasource前搜先要启用Ad Hoc Distributed Queries服务,因 ...
- SQL Server 跨服务器 不同数据库之间复制表的数据
不同数据库之间复制表的数据的方法: 当表目标表存在时: insert into 目的数据库..表 select * from 源数据库..表 当目标表不存在时: select * into 目的数据库 ...
- mysql 跨服务器复制数据库
比较了下,还是采用ssh的方式最简单.比如传数据库test_db mysqldump --databases test_db| ssh 121.121.121.121 test_db
随机推荐
- 【二】Jmeter接口自动化测试系列之函数使用及扩展
上一篇文章我们了解了Jmeter的参数化的集中方法,虽然方法不是很多,但已经足够使用! 本篇文章,介绍一下Jmeter自带函数的使用和 函数扩展,来满足测试工作中的各种需求! Jmeter自带函数 点 ...
- Java类初始化顺序,大神3个示例带你躺坑。。
最近发现微信群里面有些群友在讨论类的初始化顺序,如类的静态变量.成员变量.静态代码块.非静态代码块.构造器,及继承父类时,它们的初始化顺序都是怎样的,下面我通过例子来说明这个情况,以免被人误导. 示例 ...
- <Git>git学习
1.安装 分布式版本控制:工作电脑保存完整的代码,中央服务器挂了也可以使用 集中式版本控制:中央服务器挂了就凉凉 sudo apt-get install git git安装 检测安装成功 git 2 ...
- 46-Ubuntu-系统信息-1-date和cal查看系统时间
序号 命令 作用 01 date 查看系统时间 02 cal calendar查看日历,-y选项可以查看一年的日历
- 35-Ubuntu-组管理-01-添加组/删除组/确认组信息
组管理 提示: 创建组/删除组的终端命令都需要sudo执行,标准用户没有权限! 序号 命令 作用 01 sudo groupadd 组名 添加组 02 sudo groupdel 组名 删除组 03 ...
- 不在B中的A的子串数量 HDU - 4416 (后缀自动机模板题目)
题目: 给定一个字符串a,又给定一系列b字符串,求字符串a的子串不在b中出现的个数. 题解: 先将所有的查询串放入后缀自动机(每次将sam.last=1)(算出所有子串个数) 然后将母串放入后缀自动机 ...
- 8.Struts2拦截器
1. 拦截器的概述 * 拦截器就是AOP(Aspect-Oriented Programming)的一种实现.(AOP是指用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加入某些操作.) * ...
- jq-demo-2种吸顶效果
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- CodeForces祝贺上紫
还是靠手速了. 不少比赛,经常差几分钟/一个细节就能AC一道比较难的题目. 加油! P.S 只能当成休闲性质,不能再当成正业了.迈向科研...
- thinkphp 储存驱动
存储驱动完成了不同环境下面的文件存取操作,也是ThinkPHP支持分布式和云平台的基础. 默认的存储驱命名空间位于Think\Storage\Driver,每个存储驱动必须继承Think\Storag ...