pgadmin4中的备份与恢复

一,postgresql 数据的备份与恢复

(一)数据库备份与恢复

1,备份

windows环境

1> dump 逻辑备份

1,用管理员身份打开power shell
在这里插入图片描述
2,切换到本机 postgresql 安装目录下的 bin 目录:

PS C:\Users\DFL> cd D:\DFL\SOFTWARES\postgresql14\bin
PS D:\DFL\SOFTWARES\postgresql14\bin>

3,执行 dump ,将 test 数据库备份到桌面文件 appdb.bak :

PS D:\DFL\SOFTWARES\postgresql14\bin> .\pg_dump -h localhost -p 5432 -U postgres  -d test > C:\Users\DFL\Desktop\appdb.bak
口令:

2> COPY 逻辑备份

Linux(ubuntu)环境

(二)数据表备份与恢复

二,pgadmin4

(一)备份

1,备份 table

在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
2,备份详情:

请求参数:

gid1
sid=1
data={'file': '/student.bak.backup', 'format': 'plain', 'id': None, 'blobs': True, 'verbose': True, 'encoding': 'UTF8', 'role': 'postgres', 'only_data': True, 'use_insert_commands': True, 'include_create_database': True, 'disable_trigger': True, 'disable_quoting': True, 'database': 'postgres', 'tables': [['public', 'student']]}

pgadmin4数据备份源码:

web/pgadmin/tools/backup/__init__.py:
@blueprint.route('/job/<int:sid>', methods=['POST'], endpoint='create_server_job'
)
@blueprint.route('/job/<int:sid>/object', methods=['POST'], endpoint='create_object_job'
)
@login_required
def create_backup_objects_job(sid):"""Args:sid: Server IDCreates a new job for backup task(Backup Database(s)/Schema(s)/Table(s))Returns:None"""# 获取请求data = json.loads(request.data, encoding='utf-8')backup_obj_type = data.get('type', 'objects')try:# 获取文件路径backup_file = filename_with_file_manager_path(data['file'], (data.get('format', '') != 'directory'))except Exception as e:return bad_request(errormsg=str(e))# 获取服务器信息server = get_server(sid)if server is None:return make_json_response(success=0,errormsg=_("Could not find the specified server."))# To fetch MetaData for the serverfrom pgadmin.utils.driver import get_driverdriver = get_driver(PG_DEFAULT_DRIVER)manager = driver.connection_manager(server.id)conn = manager.connection()connected = conn.connected()if not connected:return make_json_response(success=0,errormsg=_("Please connect to the server first."))# 获取备份工具,这里是 pg_dumputility = manager.utility('backup') if backup_obj_type == 'objects' \else manager.utility('backup_server')ret_val = does_utility_exist(utility)if ret_val:return make_json_response(success=0,errormsg=ret_val)# 准备填充 dump 命令的参数# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/student.bak.backup', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--data-only', '--disable-triggers', '--create', '--inserts', '--disable-dollar-quoting', '--encoding', 'UTF8', '--table', 'public.student']args = _get_args_params_values(data, conn, backup_obj_type, backup_file, server, manager)# 这里将参数中的所有双引号转义,因为双引号在shell命令行中具有特殊含义,它们在没有双引号的情况下运行。添加额外的引号以保存我们的双引号。escaped_args = [escape_dquotes_process_arg(arg) for arg in args]try:# 用 utf-8 编码文件名bfile = data['file'].encode('utf-8') \if hasattr(data['file'], 'encode') else data['file']# 区分不同的备份类型if backup_obj_type == 'objects':    # 备份数据对象(数据库、模式、表)数据args.append(data['database'])escaped_args.append(data['database'])p = BatchProcess(desc=BackupMessage(BACKUP.OBJECT, server.id, bfile,*args,database=data['database']),cmd=utility, args=escaped_args)else:                               # 备份服务器数据p = BatchProcess(desc=BackupMessage(BACKUP.SERVER if backup_obj_type != 'globals'else BACKUP.GLOBALS,server.id, bfile,*args),cmd=utility, args=escaped_args)manager.export_password_env(p.id)# Check for connection timeout and if it is greater than 0 then# set the environment variable PGCONNECT_TIMEOUT.if manager.connect_timeout > 0:env = dict()env['PGCONNECT_TIMEOUT'] = str(manager.connect_timeout)p.set_env_variables(server, env=env)else:p.set_env_variables(server)# 创建子进程,执行 pg_dump 命令p.start()jid = p.idexcept Exception as e:current_app.logger.exception(e)return make_json_response(status=410,success=0,errormsg=str(e))# Return responsereturn make_json_response(data={'job_id': jid, 'desc': p.desc.message, 'Success': 1})

右下角显示进程任务执行信息:
在这里插入图片描述
查看进程任务:在这里插入图片描述查看备份任务执行情况:
在这里插入图片描述

查看任务务行详情:
在这里插入图片描述- 红框中就是备份数据表时执行的 dump 命令。

下载备份文件:
在这里插入图片描述
3,备份文件:

--
-- PostgreSQL database dump
---- Dumped from database version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)
-- Dumped by pg_dump version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)-- Started on 2023-08-23 18:01:11 CSTSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;--
-- TOC entry 3640 (class 1262 OID 13799)
-- Name: postgres; Type: DATABASE; Schema: -; Owner: postgres
--CREATE DATABASE postgres WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'zh_CN.UTF-8';ALTER DATABASE postgres OWNER TO postgres;\connect postgresSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;--
-- TOC entry 3634 (class 0 OID 24580)
-- Dependencies: 213
-- Data for Name: student; Type: TABLE DATA; Schema: public; Owner: postgres
--SET SESSION AUTHORIZATION DEFAULT;ALTER TABLE public.student DISABLE TRIGGER ALL;INSERT INTO public.student VALUES (1, 1, 'tname1');
INSERT INTO public.student VALUES (2, 1, 'tname1');
INSERT INTO public.student VALUES (3, 2, 'tname2');
INSERT INTO public.student VALUES (4, 3, 'tname3');
INSERT INTO public.student VALUES (5, 3, 'tname3');ALTER TABLE public.student ENABLE TRIGGER ALL;-- Completed on 2023-08-23 18:01:11 CST--
-- PostgreSQL database dump complete
--

5,备份 schema

1,对话框
在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述
在这里插入图片描述2,备份信息:

@blueprint.route('/job/<int:sid>', methods=['POST'], endpoint='create_server_job'
)
@blueprint.route('/job/<int:sid>/object', methods=['POST'], endpoint='create_object_job'
)
@login_required
def create_backup_objects_job(sid):"""Args:sid: Server IDCreates a new job for backup task(Backup Database(s)/Schema(s)/Table(s))Returns:None"""# 获取请求# {'file': 'psche', 'format': 'plain', 'id': None, 'blobs': True, 'verbose': True, 'encoding': 'UTF8', 'role': 'postgres', 'data': True, 'dns_owner': True, 'dns_tablespace': True, 'dns_unlogged_tbl_data': True, 'no_comments': True, 'use_insert_commands': True, 'include_create_database': True, 'include_drop_database': True, 'database': 'postgres', 'schemas': ['public']}data = json.loads(request.data, encoding='utf-8')# 'objects'backup_obj_type = data.get('type', 'objects')try:# 获取文件路径# '/var/lib/pgadmin/storage/dangfulin2333_163.com/psche'backup_file = filename_with_file_manager_path(data['file'], (data.get('format', '') != 'directory'))except Exception as e:return bad_request(errormsg=str(e))# 获取服务器信息# <Server 1>server = get_server(sid)if server is None:return make_json_response(success=0,errormsg=_("Could not find the specified server."))# To fetch MetaData for the serverfrom pgadmin.utils.driver import get_driverdriver = get_driver(PG_DEFAULT_DRIVER)manager = driver.connection_manager(server.id)conn = manager.connection()connected = conn.connected()if not connected:return make_json_response(success=0,errormsg=_("Please connect to the server first."))# 获取备份工具# '/usr/lib/postgresql/14/bin/pg_dump'utility = manager.utility('backup') if backup_obj_type == 'objects' \else manager.utility('backup_server')ret_val = does_utility_exist(utility)if ret_val:return make_json_response(success=0,errormsg=ret_val)# 工具参数# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/psche', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=data', '--no-tablespaces', '--no-unlogged-table-data', '--inserts', '--no-comments', '--encoding', 'UTF8', '--schema', 'public', 'postgres']args = _get_args_params_values(data, conn, backup_obj_type, backup_file, server, manager)# 这里将参数中的所有双引号转义,因为双引号在shell命令行中具有特殊含义,它们在没有双引号的情况下运行。添加额外的引号以保存我们的双引号。# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/psche', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=data', '--no-tablespaces', '--no-unlogged-table-data', '--inserts', '--no-comments', '--encoding', 'UTF8', '--schema', 'public', 'postgres']escaped_args = [escape_dquotes_process_arg(arg) for arg in args]try:# 用 utf-8 编码文件名bfile = data['file'].encode('utf-8') \if hasattr(data['file'], 'encode') else data['file']# 区分不同的备份类型if backup_obj_type == 'objects':    # 备份数据对象(数据库、模式、表)数据args.append(data['database'])# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/psche', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=data', '--no-tablespaces', '--no-unlogged-table-data', '--inserts', '--no-comments', '--encoding', 'UTF8', '--schema', 'public', 'postgres']escaped_args.append(data['database'])# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/psche', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=data', '--no-tablespaces', '--no-unlogged-table-data', '--inserts', '--no-comments', '--encoding', 'UTF8', '--schema', 'public', 'postgres']p = BatchProcess(desc=BackupMessage(BACKUP.OBJECT, server.id, bfile,*args,database=data['database']),cmd=utility, args=escaped_args)else:                               # 备份服务器数据p = BatchProcess(desc=BackupMessage(BACKUP.SERVER if backup_obj_type != 'globals'else BACKUP.GLOBALS,server.id, bfile,*args),cmd=utility, args=escaped_args)manager.export_password_env(p.id)# Check for connection timeout and if it is greater than 0 then# set the environment variable PGCONNECT_TIMEOUT.if manager.connect_timeout > 0:env = dict()env['PGCONNECT_TIMEOUT'] = str(manager.connect_timeout)p.set_env_variables(server, env=env)else:p.set_env_variables(server)# 创建子进程,执行 pg_dump 命令p.start()jid = p.idexcept Exception as e:current_app.logger.exception(e)return make_json_response(status=410,success=0,errormsg=str(e))# Return responsereturn make_json_response(data={'job_id': jid, 'desc': p.desc.message, 'Success': 1})

在这里插入图片描述3,备份文件:

--
-- PostgreSQL database dump
---- Dumped from database version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)
-- Dumped by pg_dump version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)-- Started on 2023-08-24 08:52:15 CSTSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;DROP DATABASE postgres;
--
-- TOC entry 3671 (class 1262 OID 13799)
-- Name: postgres; Type: DATABASE; Schema: -; Owner: -
--CREATE DATABASE postgres WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'zh_CN.UTF-8';\connect postgresSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;--
-- TOC entry 3662 (class 0 OID 24629)
-- Dependencies: 216
-- Data for Name: circles; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3664 (class 0 OID 25273)
-- Dependencies: 218
-- Data for Name: company6; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3665 (class 0 OID 25280)
-- Dependencies: 219
-- Data for Name: department1; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3661 (class 0 OID 24611)
-- Dependencies: 215
-- Data for Name: orders; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3660 (class 0 OID 24580)
-- Dependencies: 213
-- Data for Name: student; Type: TABLE DATA; Schema: public; Owner: -
--INSERT INTO public.student VALUES (1, 1, 'tname1');
INSERT INTO public.student VALUES (2, 1, 'tname1');
INSERT INTO public.student VALUES (3, 2, 'tname2');
INSERT INTO public.student VALUES (4, 3, 'tname3');
INSERT INTO public.student VALUES (5, 3, 'tname3');--
-- TOC entry 3663 (class 0 OID 25264)
-- Dependencies: 217
-- Data for Name: t2; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3659 (class 0 OID 24577)
-- Dependencies: 212
-- Data for Name: teacher; Type: TABLE DATA; Schema: public; Owner: -
--INSERT INTO public.teacher VALUES (1, 'sname1');
INSERT INTO public.teacher VALUES (2, 'sname2');
INSERT INTO public.teacher VALUES (3, 'sname3');-- Completed on 2023-08-24 08:52:15 CST--
-- PostgreSQL database dump complete
--

6,备份 database

1,对话框:
在这里插入图片描述在这里插入图片描述在这里插入图片描述2,备份信息:

@blueprint.route('/job/<int:sid>', methods=['POST'], endpoint='create_server_job'
)
@blueprint.route('/job/<int:sid>/object', methods=['POST'], endpoint='create_object_job'
)
@login_required
def create_backup_objects_job(sid):"""Args:sid: Server IDCreates a new job for backup task(Backup Database(s)/Schema(s)/Table(s))Returns:None"""# 获取请求# {'file': 'pdb', 'format': 'plain', 'id': None, 'blobs': True, 'verbose': True, 'encoding': 'UTF8', 'role': 'postgres', 'pre_data': True, 'data': True, 'post_data': True, 'dns_owner': True, 'dns_tablespace': True, 'use_insert_commands': True, 'include_create_database': True, 'include_drop_database': True, 'database': 'postgres'}data = json.loads(request.data, encoding='utf-8')# 'objects'backup_obj_type = data.get('type', 'objects')try:# 获取文件路径# '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb'backup_file = filename_with_file_manager_path(data['file'], (data.get('format', '') != 'directory'))except Exception as e:return bad_request(errormsg=str(e))# 获取服务器信息# <Server 1>server = get_server(sid)if server is None:return make_json_response(success=0,errormsg=_("Could not find the specified server."))# To fetch MetaData for the serverfrom pgadmin.utils.driver import get_driverdriver = get_driver(PG_DEFAULT_DRIVER)manager = driver.connection_manager(server.id)conn = manager.connection()connected = conn.connected()if not connected:return make_json_response(success=0,errormsg=_("Please connect to the server first."))# 获取备份工具# '/usr/lib/postgresql/14/bin/pg_dump'utility = manager.utility('backup') if backup_obj_type == 'objects' \else manager.utility('backup_server')ret_val = does_utility_exist(utility)if ret_val:return make_json_response(success=0,errormsg=ret_val)# 工具参数# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=pre-data', '--section=data', '--section=post-data', '--no-tablespaces', '--inserts', '--encoding', 'UTF8', 'postgres']args = _get_args_params_values(data, conn, backup_obj_type, backup_file, server, manager)# 这里将参数中的所有双引号转义,因为双引号在shell命令行中具有特殊含义,它们在没有双引号的情况下运行。添加额外的引号以保存我们的双引号。# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=pre-data', '--section=data', '--section=post-data', '--no-tablespaces', '--inserts', '--encoding', 'UTF8', 'postgres']escaped_args = [escape_dquotes_process_arg(arg) for arg in args]try:# 用 utf-8 编码文件名bfile = data['file'].encode('utf-8') \if hasattr(data['file'], 'encode') else data['file']# 区分不同的备份类型if backup_obj_type == 'objects':    # 备份数据对象(数据库、模式、表)数据args.append(data['database'])# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=pre-data', '--section=data', '--section=post-data', '--no-tablespaces', '--inserts', '--encoding', 'UTF8', 'postgres']escaped_args.append(data['database'])# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=pre-data', '--section=data', '--section=post-data', '--no-tablespaces', '--inserts', '--encoding', 'UTF8', 'postgres']p = BatchProcess(desc=BackupMessage(BACKUP.OBJECT, server.id, bfile,*args,database=data['database']),cmd=utility, args=escaped_args)else:                               # 备份服务器数据p = BatchProcess(desc=BackupMessage(BACKUP.SERVER if backup_obj_type != 'globals'else BACKUP.GLOBALS,server.id, bfile,*args),cmd=utility, args=escaped_args)manager.export_password_env(p.id)# Check for connection timeout and if it is greater than 0 then# set the environment variable PGCONNECT_TIMEOUT.if manager.connect_timeout > 0:env = dict()env['PGCONNECT_TIMEOUT'] = str(manager.connect_timeout)p.set_env_variables(server, env=env)else:p.set_env_variables(server)# 创建子进程,执行 pg_dump 命令p.start()jid = p.idexcept Exception as e:current_app.logger.exception(e)return make_json_response(status=410,success=0,errormsg=str(e))# Return responsereturn make_json_response(data={'job_id': jid, 'desc': p.desc.message, 'Success': 1})

在这里插入图片描述

3,备份文件:

--
-- PostgreSQL database dump
---- Dumped from database version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)
-- Dumped by pg_dump version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)-- Started on 2023-08-24 09:06:19 CSTSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;DROP DATABASE postgres;
--
-- TOC entry 3671 (class 1262 OID 13799)
-- Name: postgres; Type: DATABASE; Schema: -; Owner: -
--CREATE DATABASE postgres WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'zh_CN.UTF-8';\connect postgresSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;--
-- TOC entry 3672 (class 0 OID 0)
-- Dependencies: 3671
-- Name: DATABASE postgres; Type: COMMENT; Schema: -; Owner: -
--COMMENT ON DATABASE postgres IS 'default administrative connection database';--
-- TOC entry 3 (class 3079 OID 24634)
-- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: -
--CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;--
-- TOC entry 3673 (class 0 OID 0)
-- Dependencies: 3
-- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: -
--COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST';--
-- TOC entry 2 (class 3079 OID 16394)
-- Name: postgres_fdw; Type: EXTENSION; Schema: -; Owner: -
--CREATE EXTENSION IF NOT EXISTS postgres_fdw WITH SCHEMA public;--
-- TOC entry 3674 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION postgres_fdw; Type: COMMENT; Schema: -; Owner: -
--COMMENT ON EXTENSION postgres_fdw IS 'foreign-data wrapper for remote PostgreSQL servers';--
-- TOC entry 225 (class 1255 OID 24616)
-- Name: update_order_status(); Type: FUNCTION; Schema: public; Owner: -
--CREATE FUNCTION public.update_order_status() RETURNS triggerLANGUAGE plpgsqlAS $$
BEGINIF NEW.total_amount > 1000 THENNEW.status := '已审核';ELSENEW.status := '待审核';END IF;RETURN NEW;
END;
$$;--
-- TOC entry 2321 (class 2328 OID 16403)
-- Name: test1; Type: FOREIGN DATA WRAPPER; Schema: -; Owner: -
--CREATE FOREIGN DATA WRAPPER test1 HANDLER public.postgres_fdw_handler VALIDATOR public.postgres_fdw_validator;--
-- TOC entry 2322 (class 1417 OID 16401)
-- Name: server1; Type: SERVER; Schema: -; Owner: -
--CREATE SERVER server1 FOREIGN DATA WRAPPER postgres_fdw OPTIONS (dbname 'test',host '172.28.79.200',port '5432'
);--
-- TOC entry 3675 (class 0 OID 0)
-- Name: USER MAPPING postgres SERVER server1; Type: USER MAPPING; Schema: -; Owner: -
--CREATE USER MAPPING FOR postgres SERVER server1 OPTIONS (password 'postgres',"user" 'postgres'
);SET default_table_access_method = heap;--
-- TOC entry 216 (class 1259 OID 24629)
-- Name: circles; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.circles (c circle
);--
-- TOC entry 218 (class 1259 OID 25273)
-- Name: company6; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.company6 (id integer NOT NULL,name text NOT NULL,age integer NOT NULL,address character(50),salary real
);--
-- TOC entry 219 (class 1259 OID 25280)
-- Name: department1; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.department1 (id integer NOT NULL,dept character(50) NOT NULL,emp_id integer NOT NULL
);--
-- TOC entry 211 (class 1259 OID 16405)
-- Name: ft1; Type: FOREIGN TABLE; Schema: public; Owner: -
--CREATE FOREIGN TABLE public.ft1 (port integer
)
SERVER server1;--
-- TOC entry 215 (class 1259 OID 24611)
-- Name: orders; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.orders (id integer NOT NULL,order_date date,total_amount numeric(10,2),status character varying(20)
);--
-- TOC entry 213 (class 1259 OID 24580)
-- Name: student; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.student (sid integer NOT NULL,teacher_id integer DEFAULT 0 NOT NULL,tname character varying(100)
);--
-- TOC entry 212 (class 1259 OID 24577)
-- Name: teacher; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.teacher (id integer NOT NULL,sname character varying(100)
);--
-- TOC entry 214 (class 1259 OID 24584)
-- Name: student_view; Type: VIEW; Schema: public; Owner: -
--CREATE VIEW public.student_view ASSELECT student.sid,student.teacher_id,student.tname,teacher.id,teacher.snameFROM (public.studentLEFT JOIN public.teacher ON ((student.teacher_id = teacher.id)));--
-- TOC entry 217 (class 1259 OID 25264)
-- Name: t2; Type: TABLE; Schema: public; Owner: -
--CREATE TABLE public.t2 (c1 integer,c2 text
);--
-- TOC entry 3662 (class 0 OID 24629)
-- Dependencies: 216
-- Data for Name: circles; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3664 (class 0 OID 25273)
-- Dependencies: 218
-- Data for Name: company6; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3665 (class 0 OID 25280)
-- Dependencies: 219
-- Data for Name: department1; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3661 (class 0 OID 24611)
-- Dependencies: 215
-- Data for Name: orders; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3660 (class 0 OID 24580)
-- Dependencies: 213
-- Data for Name: student; Type: TABLE DATA; Schema: public; Owner: -
--INSERT INTO public.student VALUES (1, 1, 'tname1');
INSERT INTO public.student VALUES (2, 1, 'tname1');
INSERT INTO public.student VALUES (3, 2, 'tname2');
INSERT INTO public.student VALUES (4, 3, 'tname3');
INSERT INTO public.student VALUES (5, 3, 'tname3');--
-- TOC entry 3663 (class 0 OID 25264)
-- Dependencies: 217
-- Data for Name: t2; Type: TABLE DATA; Schema: public; Owner: -
----
-- TOC entry 3659 (class 0 OID 24577)
-- Dependencies: 212
-- Data for Name: teacher; Type: TABLE DATA; Schema: public; Owner: -
--INSERT INTO public.teacher VALUES (1, 'sname1');
INSERT INTO public.teacher VALUES (2, 'sname2');
INSERT INTO public.teacher VALUES (3, 'sname3');--
-- TOC entry 3513 (class 2606 OID 24633)
-- Name: circles circles_c_excl; Type: CONSTRAINT; Schema: public; Owner: -
--ALTER TABLE ONLY public.circlesADD CONSTRAINT circles_c_excl EXCLUDE USING gist (c WITH &&);--
-- TOC entry 3515 (class 2606 OID 25279)
-- Name: company6 company6_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--ALTER TABLE ONLY public.company6ADD CONSTRAINT company6_pkey PRIMARY KEY (id);--
-- TOC entry 3517 (class 2606 OID 25284)
-- Name: department1 department1_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--ALTER TABLE ONLY public.department1ADD CONSTRAINT department1_pkey PRIMARY KEY (id);--
-- TOC entry 3511 (class 2606 OID 24615)
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--ALTER TABLE ONLY public.ordersADD CONSTRAINT orders_pkey PRIMARY KEY (id);--
-- TOC entry 3508 (class 2606 OID 25272)
-- Name: student student_ck; Type: CHECK CONSTRAINT; Schema: public; Owner: -
--ALTER TABLE public.studentADD CONSTRAINT student_ck CHECK ((sid > 0)) NOT VALID;--
-- TOC entry 3676 (class 0 OID 0)
-- Dependencies: 3508
-- Name: CONSTRAINT student_ck ON student; Type: COMMENT; Schema: public; Owner: -
--COMMENT ON CONSTRAINT student_ck ON public.student IS '检查约束';--
-- TOC entry 3518 (class 1259 OID 25290)
-- Name: fki_C; Type: INDEX; Schema: public; Owner: -
--CREATE INDEX "fki_C" ON public.department1 USING btree (emp_id);--
-- TOC entry 3509 (class 1259 OID 24604)
-- Name: index_test; Type: INDEX; Schema: public; Owner: -
--CREATE INDEX index_test ON public.student USING btree (tname COLLATE "C" bpchar_pattern_ops);--
-- TOC entry 3677 (class 0 OID 0)
-- Dependencies: 3509
-- Name: INDEX index_test; Type: COMMENT; Schema: public; Owner: -
--COMMENT ON INDEX public.index_test IS '测试';-- Completed on 2023-08-24 09:06:20 CST--
-- PostgreSQL database dump complete
--

7,备份服务器

1,对话框
在这里插入图片描述在这里插入图片描述
在这里插入图片描述

2,备份信息

@blueprint.route('/job/<int:sid>', methods=['POST'], endpoint='create_server_job'
)
@blueprint.route('/job/<int:sid>/object', methods=['POST'], endpoint='create_object_job'
)
@login_required
def create_backup_objects_job(sid):"""Args:sid: Server IDCreates a new job for backup task(Backup Database(s)/Schema(s)/Table(s))Returns:None"""# 获取请求# {'file': 'localhostserver', 'format': 'plain', 'id': None, 'blobs': False, 'verbose': True, 'encoding': 'UTF8', 'role': 'postgres', 'only_data': True, 'dns_owner': True, 'dns_privilege': True, 'dns_tablespace': True, 'use_insert_commands': True, 'disable_trigger': True, 'disable_quoting': True, 'type': 'server'}data = json.loads(request.data, encoding='utf-8')# 'server'backup_obj_type = data.get('type', 'objects')try:# 获取文件路径# '/var/lib/pgadmin/storage/dangfulin2333_163.com/localhostserver'backup_file = filename_with_file_manager_path(data['file'], (data.get('format', '') != 'directory'))except Exception as e:return bad_request(errormsg=str(e))# 获取服务器信息# <Server 1>server = get_server(sid)if server is None:return make_json_response(success=0,errormsg=_("Could not find the specified server."))# To fetch MetaData for the serverfrom pgadmin.utils.driver import get_driverdriver = get_driver(PG_DEFAULT_DRIVER)manager = driver.connection_manager(server.id)conn = manager.connection()connected = conn.connected()if not connected:return make_json_response(success=0,errormsg=_("Please connect to the server first."))# 获取备份工具# '/usr/lib/postgresql/14/bin/pg_dumpall'utility = manager.utility('backup') if backup_obj_type == 'objects' \else manager.utility('backup_server')ret_val = does_utility_exist(utility)if ret_val:return make_json_response(success=0,errormsg=ret_val)# 工具参数# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/localhostserver', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--database', 'postgres', '--verbose', '--role', 'postgres', '--data-only', '--disable-triggers', '--no-owner', '--no-privileges', '--no-tablespaces', '--inserts', '--disable-dollar-quoting', '--encoding', 'UTF8']args = _get_args_params_values(data, conn, backup_obj_type, backup_file, server, manager)# 这里将参数中的所有双引号转义,因为双引号在shell命令行中具有特殊含义,它们在没有双引号的情况下运行。添加额外的引号以保存我们的双引号。# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/localhostserver', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--database', 'postgres', '--verbose', '--role', 'postgres', '--data-only', '--disable-triggers', '--no-owner', '--no-privileges', '--no-tablespaces', '--inserts', '--disable-dollar-quoting', '--encoding', 'UTF8']escaped_args = [escape_dquotes_process_arg(arg) for arg in args]try:# 用 utf-8 编码文件名# '/var/lib/pgadmin/storage/dangfulin2333_163.com/localhostserver'bfile = data['file'].encode('utf-8') \if hasattr(data['file'], 'encode') else data['file']# 区分不同的备份类型if backup_obj_type == 'objects':    # 备份数据对象(数据库、模式、表)数据args.append(data['database'])# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=pre-data', '--section=data', '--section=post-data', '--no-tablespaces', '--inserts', '--encoding', 'UTF8', 'postgres']escaped_args.append(data['database'])# ['--file', '/var/lib/pgadmin/storage/dangfulin2333_163.com/pdb', '--host', '127.0.0.1', '--port', '5432', '--username', 'postgres', '--no-password', '--verbose', '--role', 'postgres', '--format=p', '--no-owner', '--create', '--clean', '--section=pre-data', '--section=data', '--section=post-data', '--no-tablespaces', '--inserts', '--encoding', 'UTF8', 'postgres']p = BatchProcess(desc=BackupMessage(BACKUP.OBJECT, server.id, bfile,*args,database=data['database']),cmd=utility, args=escaped_args)else:                               # 备份服务器数据p = BatchProcess(desc=BackupMessage(BACKUP.SERVER if backup_obj_type != 'globals'else BACKUP.GLOBALS,server.id, bfile,*args),cmd=utility, args=escaped_args)manager.export_password_env(p.id)# Check for connection timeout and if it is greater than 0 then# set the environment variable PGCONNECT_TIMEOUT.if manager.connect_timeout > 0:env = dict()env['PGCONNECT_TIMEOUT'] = str(manager.connect_timeout)p.set_env_variables(server, env=env)else:p.set_env_variables(server)# 创建子进程,执行 pg_dump 命令p.start()jid = p.idexcept Exception as e:current_app.logger.exception(e)return make_json_response(status=410,success=0,errormsg=str(e))# Return responsereturn make_json_response(data={'job_id': jid, 'desc': p.desc.message, 'Success': 1})

在这里插入图片描述- 与备份表、schema、database 时使用 dump 不同的是,备份 server 时使用 dumpall

3,备份文件

--
-- PostgreSQL database cluster dump
---- Started on 2023-08-24 09:15:36 CSTSET default_transaction_read_only = off;SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;--
-- Databases
----
-- Database "template1" dump
--\connect template1--
-- PostgreSQL database dump
---- Dumped from database version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)
-- Dumped by pg_dump version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)-- Started on 2023-08-24 09:15:36 CSTSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;-- Completed on 2023-08-24 09:15:36 CST--
-- PostgreSQL database dump complete
----
-- Database "postgres" dump
--\connect postgres--
-- PostgreSQL database dump
---- Dumped from database version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)
-- Dumped by pg_dump version 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)-- Started on 2023-08-24 09:15:36 CSTSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;--
-- TOC entry 3660 (class 0 OID 24629)
-- Dependencies: 216
-- Data for Name: circles; Type: TABLE DATA; Schema: public; Owner: -
--SET SESSION AUTHORIZATION DEFAULT;ALTER TABLE public.circles DISABLE TRIGGER ALL;ALTER TABLE public.circles ENABLE TRIGGER ALL;--
-- TOC entry 3662 (class 0 OID 25273)
-- Dependencies: 218
-- Data for Name: company6; Type: TABLE DATA; Schema: public; Owner: -
--ALTER TABLE public.company6 DISABLE TRIGGER ALL;ALTER TABLE public.company6 ENABLE TRIGGER ALL;--
-- TOC entry 3663 (class 0 OID 25280)
-- Dependencies: 219
-- Data for Name: department1; Type: TABLE DATA; Schema: public; Owner: -
--ALTER TABLE public.department1 DISABLE TRIGGER ALL;ALTER TABLE public.department1 ENABLE TRIGGER ALL;--
-- TOC entry 3659 (class 0 OID 24611)
-- Dependencies: 215
-- Data for Name: orders; Type: TABLE DATA; Schema: public; Owner: -
--ALTER TABLE public.orders DISABLE TRIGGER ALL;ALTER TABLE public.orders ENABLE TRIGGER ALL;--
-- TOC entry 3658 (class 0 OID 24580)
-- Dependencies: 213
-- Data for Name: student; Type: TABLE DATA; Schema: public; Owner: -
--ALTER TABLE public.student DISABLE TRIGGER ALL;INSERT INTO public.student VALUES (1, 1, 'tname1');
INSERT INTO public.student VALUES (2, 1, 'tname1');
INSERT INTO public.student VALUES (3, 2, 'tname2');
INSERT INTO public.student VALUES (4, 3, 'tname3');
INSERT INTO public.student VALUES (5, 3, 'tname3');ALTER TABLE public.student ENABLE TRIGGER ALL;--
-- TOC entry 3661 (class 0 OID 25264)
-- Dependencies: 217
-- Data for Name: t2; Type: TABLE DATA; Schema: public; Owner: -
--ALTER TABLE public.t2 DISABLE TRIGGER ALL;ALTER TABLE public.t2 ENABLE TRIGGER ALL;--
-- TOC entry 3657 (class 0 OID 24577)
-- Dependencies: 212
-- Data for Name: teacher; Type: TABLE DATA; Schema: public; Owner: -
--ALTER TABLE public.teacher DISABLE TRIGGER ALL;INSERT INTO public.teacher VALUES (1, 'sname1');
INSERT INTO public.teacher VALUES (2, 'sname2');
INSERT INTO public.teacher VALUES (3, 'sname3');ALTER TABLE public.teacher ENABLE TRIGGER ALL;-- Completed on 2023-08-24 09:15:36 CST--
-- PostgreSQL database dump complete
---- Completed on 2023-08-24 09:15:36 CST--
-- PostgreSQL database cluster dump complete
--

(二)恢复

1,恢复 table

1,恢复 schema

1,恢复 db

1,恢复 database

三,

四,

五,

六,

(一)

(二)

(四)

(五)

(六)

(七)

(八)

(九)

(十)

(十一)

1,

2,

3,

4,

5,

6,

7,

8,

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

《PostgreSQL 开发指南》第 08 篇 备份与恢复

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/106230.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

win开机自启jar包

下载winsw工具 只需下载图中红框的工具 https://github.com/winsw/winsw/releases 文件配置 将下载的文件与jar文件放置在一起&#xff0c;两个文件名修改为服务名 编辑xml文件 注意不要出现中文&#xff0c; 标签内的jar文件地址要改为自己目录 <service><!-- I…

MySQL每日一练--校园教务系统

一丶数据库名称&#xff1a;SchoolDB 二丶数据库表信息&#xff1a;角色信息表 表名&#xff1a; t_role 主键&#xff1a; r_id 序号 字段名称 字段说明 类别 位数 属性 备注 1 r_id 角色编号 int 主键 自动增长 2 r_name_EN 角色名&#xff08;英…

快速排序三种思路详解!

一、快速排序的介绍 快速排序是Hoare于1962年提出的一种二叉树结构的交换排序方法&#xff0c;其基本思想为&#xff1a;任取待排序元素序列中 的某元素作为基准值&#xff0c;按照该排序码将待排序集合分割成两子序列&#xff0c;左子序列中所有元素均小于基准值&#xff0c;…

<C++>泛型编程-模板

1.泛型编程 如何实现一个通用的交换函数呢&#xff1f;可以使用函数重载 void Swap(int &left, int &right) {int temp left;left right;right temp; }void Swap(double &left, double &right) {double temp left;left right;right temp; }void Swap(c…

基于YOLOv8模型和DarkFace数据集的黑夜人脸检测系统(PyTorch+Pyside6+YOLOv8模型)

摘要&#xff1a;基于YOLOv8模型和DarkFace数据集的黑夜人脸检测系统可用于日常生活中检测与定位黑夜下的人脸&#xff0c;利用深度学习算法可实现图片、视频、摄像头等方式的目标检测&#xff0c;另外本系统还支持图片、视频等格式的结果可视化与结果导出。本系统采用YOLOv8目…

开源与专有软件:比较与对比

&#x1f337;&#x1f341; 博主猫头虎 带您 Go to New World.✨&#x1f341; &#x1f984; 博客首页——猫头虎的博客&#x1f390; &#x1f433;《面试题大全专栏》 文章图文并茂&#x1f995;生动形象&#x1f996;简单易学&#xff01;欢迎大家来踩踩~&#x1f33a; &a…

kafka--技术文档--基本docker中安装<单机>-linux

安装zookeeper 阿丹小科普&#xff1a; Kafka在0.11.0.0版本之后不再依赖Zookeeper&#xff0c;而是使用基于Raft协议的Kafka自身的仲裁机制来替代Zookeeper。具体来说&#xff0c;Kafka 2.8.0版本是第一个不需要Zookeeper就可以运行Kafka的版本&#xff0c;这被称为Kafka Raf…

Mysql索引+事务+存储引擎

一、索引 1.1 索引的概念 -索引是一个排序的列表&#xff0c;在这个列表中存储着索引的值和包含这个值的数据所在行的物理地址&#xff08;类似于c语言的链表通过指针指向数据记录的内存地址&#xff09; -使用索引后可以不用扫描全表来定位某行的数据&#xff0c;而是先通过索…

java八股文面试[java基础]——浅拷贝和深拷贝

自验证&#xff1a;创建Class Student两个类&#xff0c; Student中含有Class对象 public class Class implements Cloneable {public String getName() {return name;}public void setName(String name) {this.name name;}private String name;public Class(String name) {t…

ssm+vue农家乐信息平台源码和论文

ssmvue农家乐信息平台源码和论文066 开发工具&#xff1a;idea 数据库mysql5.7 数据库链接工具&#xff1a;navcat,小海豚等 技术&#xff1a;ssm 1、研究现状 国外&#xff0c;农家乐都被作为潜在的发展农村经济&#xff0c;增加农民收入的重要手段&#xff0c;让农户广…

Stable Diffusion 系列教程 | 图生图基础

前段时间有一个风靡全网的真人转漫画风格&#xff0c;受到了大家的喜欢 而在SD里&#xff0c;就可以通过图生图来实现类似的效果 当然图生图还有更好玩的应用&#xff0c;我们一点一点来探索 首先我们来简单进行一下图生图的这一个实践---真人转动漫 1. 图生图基本界面 和…

基于Java+SpringBoot+Vue前后端分离医院资源管理系统设计和实现

博主介绍&#xff1a;✌全网粉丝30W,csdn特邀作者、博客专家、CSDN新星计划导师、Java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专…

使用Python批量将飞书文档转为MD

说明&#xff1a;飞书是在线文档平台&#xff0c;本文介绍如何使用Python程序批量将飞书文档转为MD文档&#xff0c;并下载到本地&#xff1b; 复制地址 首先&#xff0c;把文档的URL都复制下来&#xff0c;这个需要一个一个点&#xff0c;并复制拷贝&#xff0c;但却是工作量…

代码评审(Code Review)规范

一、目的 Code Review是一种用来确认方案设计和代码实现的质量保证机制&#xff0c;通过这个机制我们 可以对代码、测试过程和注释进行检查。 Code Review主要用来在软件工程过程中改进代码质量&#xff0c;通过Code Review可以达到 如下目的&#xff1a; 1) 在项目早期就能够…

微服务(多级缓存)

目录 多级缓存 1.什么是多级缓存 2.JVM进程缓存 2.2.初识Caffeine 2.3.实现JVM进程缓存 2.3.1.需求 2.3.2.实现 3.Lua语法入门 3.1.初识Lua 3.1.HelloWorld 3.2.变量和循环 3.2.1.Lua的数据类型 3.2.2.声明变量 3.2.3.循环 3.3.条件控制、函数 3.3.1.函数 3.3.…

章节 2:轻松入手JSX -《React.js手把手教程:从初学者到实战高手》- 第一部分:React.js基础

《React.js手把手教程&#xff1a;从初学者到实战高手》 第一部分&#xff1a;React.js基础 章节 2&#xff1a;轻松入手JSX 在上一章节中&#xff0c;我们初步认识了React.js。现在&#xff0c;我们将更深入地探索React.js中的JSX&#xff08;JavaScript XML&#xff09;语法…

JVM 之字节码(.class)文件

本文中的内容参考B站尚硅谷宋红康JVM全套教程 你将获得&#xff1a; 1、掌握字节码文件的结构 2、掌握Java源代码如何在JVM中执行 3、掌握一些虚拟机指令 4、回答一些面试题 课程介绍 通过几个面试题初始字节码文件为什么学习class字节码文件什么是class字节码文件分析c…

设计模式-适配器模式

目录 1 概念介绍 1.1 基本介绍 1.2 工作原理 2 详细介绍 2.1 类适配器 2.2 对象适配器 2.3 接口适配器 3 注意事项和细节 1 概念介绍 1.1 基本介绍 适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示&#xff0c;主的目的是兼容性&#xf…

线程池也就那么一回事嘛!

线程池详讲 一、线程池的概述二、线程池三、自定义线程池四、线程池工作流程图五、线程池应用场景 一、线程池的概述 线程池其实就是一种多线程处理形式&#xff0c;处理过程中可以将任务添加到队列中&#xff0c;然后在创建线程后自动启动这些任务。这里的线程就是我们前面学过…

拥塞控制(TCP限制窗口大小的机制)

拥塞控制机制可以使滑动窗口在保证可靠性的前提下&#xff0c;提高传输效率 关于滑动窗口的属性以及部分机制推荐看TCP中窗口和滑动窗口的含义以及流量控制 拥塞控制出现的原因 看了上面推荐的博客我们已经知道了&#xff0c;由于接收方接收数据的能力有限&#xff0c;所以要通…