0. 准备工作

linux机器上面 必须安装上pg数据库
然后 需要将 pg的主程序目录 放到环境变量里面去 便于执行命令.

1. 先备份

. 备份目标数据库:
pg_dump -h 10.24.193.25 -U postgres -p -F c -f /TestPG/TestDS0816.dmp TestDS0816
# -h 小写 指向目标服务器
# -U 大写 使用的用户
# -p 小写 pg 数据库使用的端口.
# -F 指代导出格式. c 只的就是 自定义的pg_dump格式.
# -f 指代目录
# 目标数据库在最后面. man的内容为:
-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 and also supports
parallel dumps. 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.

2. 创建用户以及创建数据库

登录数据库

 psql -U postgres

创建用户以及创建数据库 注意 这里面有很大的一个坑  创建的时候 不区分大小写 ,但是因为恢复的区分大小写,所以必须添加 "" 双引号括住 数据库和用户的名字才可以.
(感谢平台部 刘威 协助..这一块坑了我半个多小时.) 创建用户
create role "TestDS0816" superuser login;
创建数据库
create database "TestDS0816" ;
设置密码
alter role "TestDS0816" with password 'Test6530';
退出数据库的命令为:
\q

3.执行恢复

pg_restore -U postgres -d TestDS0816 /TestPG/TestDS0816.dmp
# -U 大写 用户
# -d 小写指代目标.

[完整版]Postgresql 数据库 备份以及恢复的过程的更多相关文章

  1. postgresql数据库备份和恢复

    PostgreSQL自带一个客户端pgAdmin,里面有个备份,恢复选项,也能对数据库进行备份 恢复(还原),但最近发现数据库慢慢庞大的时候,经常出错,备份的文件过程中出错的几率那是相当大,手动调节灰 ...

  2. postgresql数据库备份和恢复(超快)

    PostgreSQL自带一个客户端pgAdmin,里面有个备份,恢复选项,也能对数据库进行备份 恢复(还原),但最近发现数据库慢慢庞大的时候,经常出错,备份的文件过程中出错的几率那是相当大,手动调节灰 ...

  3. 12 postgresql数据库备份和恢复

    数据表结构备份与恢复 备份 1.找到postgres 安装目录,在找到bin文件夹,会看到一堆exe后缀的文件,用win+r 打开cmd,将pg_dump.exe 拖进cmd黑窗口中 2.基本语法:- ...

  4. 小型网站MYSQL问题二:Percona Xtrabackup实现数据库备份和恢复

    1.安装软件仓库(不要问我为什么不用源码安装,好吧,其实我懒.) 1 2 3 4 5 6 7 8 wget https://www.percona.com/downloads/percona-rele ...

  5. PostgreSQL 数据库备份与还原

    PostgreSQL 数据库备份与还原 目录 备份 还原 栗子 备份 PostgreSQL提供的一个工具pg_dump,逻辑导出数据,生成sql文件或其他格式文件,pg_dump是一个客户端工具,可以 ...

  6. Sql Server数据库备份和恢复:原理篇

    本文与您探讨为什么Sql Server有完整备份.差异备份和事务日志备份三种备份方式,以及为什么数据库又有简单模式.完整模式和大容量日志模式这三种恢复模式.本文内容适用于2005以上所有版本的Sql ...

  7. PostgreSQL的备份和恢复

    关于PostgreSQL的备份和恢复详细信息请参阅<PostgreSQL中文文档>. 备份: #pg_dump --username=postgres v70_demo > v70_ ...

  8. 使用exp&imp工具进行数据库备份及恢复

    使用exp&imp工具进行数据库备份及恢复1.exp/imp使用方法介绍exp/imp为一种数据库备份恢复工具,也可以作为不同数据库之间传递数据的工具,两个数据库所在的操作系统可以不同.exp ...

  9. MongoDB学习总结(六) —— 数据库备份和恢复

    我们都知道数据库数据经常备份是多么的重要,MongoDB作为一个数据库系统,自然提供了完善,丰富而且好用的备份与恢复机制. 以下介绍三种数据库备份和恢复的方式 > 数据目录直接拷贝 数据库目录直 ...

随机推荐

  1. 2019年JVM最新面试题,必须收藏它

    1.JVN内存结构 方法区和对是所有线程共享的内存区域:而java栈.本地方法栈和程序员计数器是运行是线程私有的内存区域. Java堆(Heap),是Java虚拟机所管理的内存中最大的一块.Java堆 ...

  2. 基于WEB的网上购物系统-ssh源码

    基于WEB的网上购物系统主要功能包括:前台用户登录退出.注册.在线购物.修改个人信息.后台商品管理等等.本系统结构如下:(1)商品浏览模块:        实现浏览最新商品        实现按商品名 ...

  3. maven-dependencies插件的模拟实现

    maven-dependencies插件的作用就是从本地的maven仓库中提取jar包,放到某个文件夹下面.这个功能其实是很简单的. 我在一家银行工作时,公司电脑都无法连外网,所以无法通过maven下 ...

  4. 【已采纳】新项目第一次怎么上传到github里面

      言归正传,最近学习了怎么将新创建的本地代码上传到github上,这里简单的记录一下,我喜欢使用命令行,这里全用命令行来实现,不了解git命令的可以去了解下. 第一步:建立git仓库 cd到你的本地 ...

  5. supervisor 管理应用程序

    supervisor 进程管理 主要包含后台进程 supervisord 和控制台 supervisorctl 两个程序 supervisor # 官方文档 http://www.supervisor ...

  6. flask的request如何获取参数

    1.request.form.get("key", type=str, default=None) 获取表单数据 2.request.args.get("key" ...

  7. Lp距离, L1范数, 和L2范数(转载)

    范式可以理解成距离 转载自: https://blog.csdn.net/hanhuili/article/details/52079590 内容如下: 由此可见,L2其实就是欧式距离.工程上,往往不 ...

  8. 04-numpy-笔记-transpose

    借鉴代码https://blog.csdn.net/xiongchengluo1129/article/details/79017142 吐槽一下CSDN的垃圾广告.. 这是转置,所以1维(向量)和2 ...

  9. [笔记] nice-upload 与 nice-static-server

    1.request 支持流模式,管道流pipe,抓取图片并保存就很方便了 request('https://s.gravatar.com/avatar/184a1f14c759795b94ae1d01 ...

  10. Spring Cloud版本 version命名说明 (Edgware)

    Spring Cloud版本 version命名说明 (Edgware)   版权声明:guofangsky 版权所有,转载不究. https://blog.csdn.net/guofangsky/a ...