{"id":323125,"date":"2021-05-14T15:00:35","date_gmt":"2021-05-14T15:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=323125"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=323125","title":{"rendered":"\u042d\u0442\u044e\u0434 \u2014 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f pg_dump"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043a\u043e\u043f\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u2014 \u0431\u0435\u043a\u0430\u043f\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439 \u0441\u0432\u0435\u0440\u043a\u0438 \u0438 \u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445. <\/p>\n<p>  <b>\u041f\u0435\u0440\u0432\u043e\u0435 \u0438 \u0441\u0430\u043c\u043e\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 pg_dump<\/b><br \/>  \u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0428\u0442\u0430\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0412\u0441\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0432\u0435\u043b\u0438\u043a\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<br \/>  <b>\u041d\u043e<\/b>, \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. <br \/>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445-\u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043c\u043f\u043e\u0432.<br \/>  \u0412\u043e \u0432\u0442\u043e\u0440\u044b\u0445-\u0438 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435, \u0431\u044b\u043b\u0438 \u0441\u043b\u0443\u0447\u0430\u0438 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0411\u0414 \u043f\u0440\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u0437 \u0434\u0430\u043c\u043f\u0430. <br \/>  \u0412 \u0442\u0440\u0435\u0442\u044c\u0438\u0445-\u0432\u0440\u0435\u043c\u044f, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0430\u043c\u043f\u0430, \u043f\u043e\u0442\u043e\u043c \u043d\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0411\u0414 \u0438\u0437 \u0434\u0430\u043c\u043f\u0430.<\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u0414 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438. \u0411\u0438\u0437\u043d\u0435\u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b, \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f. <br \/>  \u041d\u0435 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e\/\u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043e. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u044e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 PostgreSQL, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c.<a name=\"habracut\"><\/a><br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0437\u0430\u043c\u0435\u043d\u044b pg_dump, \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u0414 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438, \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0438\u0434\u0435\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 PostgreSQL.<\/p>\n<h3>\u0422\u0435\u0440\u043c\u0438\u043d\u044b \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p><i><b>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 <\/b>-\u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0411\u0414 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<br \/>  <b>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0411\u0414<\/b> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0411\u0414 \u043d\u0430 <b>\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435<\/b> <br \/>  <b>\u041a\u043b\u043e\u043d \u0411\u0414<\/b> \u2014 \u043a\u043e\u043f\u0438\u044f <b>\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0411\u0414<\/b> \u043d\u0430 <b>\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435<\/b><br \/>  <b>\u041a\u043b\u0430\u0441\u0442\u0435\u0440 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0439 \u0411\u0414<\/b> \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 PostgreSQL.<br \/>  <b>\u041a\u043e\u043f\u0438\u044f \u0411\u0414<\/b>-\u0446\u0435\u043b\u0435\u0432\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u0411\u0414 \u043d\u0430 <b>\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0439 \u0411\u0414<\/b><br \/>  <\/i><br \/>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 bash-\u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u043e\u0433\u043e \u043d\u0430 <b>\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0439 \u0411\u0414<\/b>, \u0438 <b>\u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e<\/b>, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u043e\u0432.<\/p>\n<h4>\u0428\u0430\u0433 1.<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f <b>\u043a\u043b\u043e\u043d \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"pgsql\">CREATE DATABASE ... TEMPLATE = \u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0411\u0414<\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">CLONE_DB=$source_db_name'_'$timestamp_label psql -h $source_host_name -U postgres -Aqt -c &quot;UPDATE pg_database SET datallowconn = FALSE WHERE datname = '$source_db_name'&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1 psql -h $source_host_name -U postgres -Aqt -c &quot;SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='$source_db_name'&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1 psql -h $source_host_name -U postgres -Aqt -c &quot;CREATE DATABASE $CLONE_DB TEMPLATE=$source_db_name &quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1 psql -h $source_host_name -U postgres -Aqt -c &quot;UPDATE pg_database SET datallowconn = TRUE WHERE datname = '$source_db_name'&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h4>\u0428\u0430\u0433 2.<\/h4>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441\u0445\u0435\u043c\u0430 <b>\u043a\u043b\u043e\u043d\u0430 \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"bash\">pg_dump --shema_only --file=$DUMP_FILE ... <\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">pg_dump -h $source_host_name -U postgres --schema-only --verbose --file=$DUMP_FILE $source_db_name 2&gt;$SCHEMA_DUMP_LOG_FILE<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h4>\u0428\u0430\u0433 3.<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u0430\u044f \u0411\u0414 <b>\u043a\u043e\u043f\u0438\u044f \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"bash\">createdb ... <\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">createdb $CLONE_DB<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h4>\u0428\u0430\u0433 4. <\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0445\u0435\u043c\u0430 <b>\u043a\u043b\u043e\u043d\u0430 \u0411\u0414<\/b> \u0432 <b>\u043a\u043e\u043f\u0438\u0438 \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"bash\">psql ... &lt; $DUMP_FILE<\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">TARGET_SCHEMA_DUMP_LOG_FILE=$FILE_LABEL'target.log' psql -U postgres -d $CLONE_DB  &lt; $DUMP_FILE &gt; $TARGET_SCHEMA_DUMP_LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h4>\u0428\u0430\u0433 5.<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<br \/>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 <b>\u043a\u043b\u043e\u043d\u0435 \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"pgsql\">CREATE PUBLICATION ... FOR ALL TABLES <\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">PUBLICATION_NAME=$CLONE_DB'_pub' psql -h $source_host_name -U postgres -d $CLONE_DB  -c &quot;CREATE PUBLICATION $PUBLICATION_NAME FOR ALL TABLES &quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0432 <b>\u043a\u043e\u043f\u0438\u0438 \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"pgsql\">CREATE SUBSCRIPTION ...<\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">SUBSCRIPTION_NAME=$CLONE_DB'_sub' CONNECTION_STR=&quot;CREATE SUBSCRIPTION $SUBSCRIPTION_NAME CONNECTION 'host=$source_host_name port=5432 user=postgres dbname=$CLONE_DB' PUBLICATION $PUBLICATION_NAME&quot; psql -U postgres -d $CLONE_DB  -c &quot;$CONNECTION_STR&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<p>  <b>\u0428\u0430\u0433 6.<\/b>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f <b>\u043a\u043b\u043e\u043d\u0430 \u0411\u0414<\/b> \u0438 <b>\u043a\u043e\u043f\u0438\u0438 \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"pgsql\">SELECT count(*) FROM pg_stat_subscription WHERE subname =... AND relid IS NOT NULL<\/code><\/pre>\n<p> \u0411\u0414 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438. <b>\u041a\u043b\u043e\u043d \u0411\u0414 <\/b> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0431\u0430\u0437.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">flag=0 while [[ $flag = '0' ]]; do     COUNT_STR=&quot;SELECT count(*) FROM pg_stat_subscription WHERE subname ='$SUBSCRIPTION_NAME' AND relid IS NOT NULL &quot;     subscription_process_count=`psql -At -U postgres -d $CLONE_DB -c &quot;$COUNT_STR&quot;`     if [[ $subscription_process_count = '0' ]];     then         break     fi     sleep 60 done<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h4>\u0428\u0430\u0433 6.<\/h4>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"pgsql\">DROP SUBSCRIPTION...<\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">psql -d $CLONE_DB -Aqt -c &quot;DROP SUBSCRIPTION $SUBSCRIPTION_NAME&quot; &gt;&gt; $LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<pre><code class=\"pgsql\">DROP PUBLICATION ...<\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">psql -h $source_host_name  -d $CLONE_DB -Aqt -c &quot;DROP PUBLICATION $PUBLICATION_NAME&quot; &gt;&gt; $LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<p> \u0432 <b>\u043a\u043e\u043f\u0438\u0438 \u0411\u0414<\/b> \u0438 <b>\u043a\u043b\u043e\u043d\u0435 \u0411\u0414 <\/b> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.  <\/p>\n<h4>\u0428\u0430\u0433 7.<\/h4>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u044c <b>\u043a\u043b\u043e\u043d \u0411\u0414<\/b>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <\/p>\n<pre><code class=\"pgsql\">DROP DATABASE ...<\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">psql -h $source_host_name -U postgres -Aqt -c &quot;UPDATE pg_database SET datallowconn = FALSE WHERE datname = '$CLONE_DB'&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1 psql -h $source_host_name -U postgres -Aqt -c &quot;SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='$CLONE_DB'&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1 psql -h $source_host_name -U postgres -Aqt -c &quot;DROP DATABASE $CLONE_DB &quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1 psql -h $source_host_name -U postgres -Aqt -c &quot;UPDATE pg_database SET datallowconn = TRUE WHERE datname = '$CLONE_DB'&quot; &gt;&gt;$LOG_FILE 2&gt;&amp;1<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h3>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0411\u0414 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0430\u043c\u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/555854\/\"> https:\/\/habr.com\/ru\/post\/555854\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043a\u043e\u043f\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u2014 \u0431\u0435\u043a\u0430\u043f\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439 \u0441\u0432\u0435\u0440\u043a\u0438 \u0438 \u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445. <\/p>\n<p>  <b>\u041f\u0435\u0440\u0432\u043e\u0435 \u0438 \u0441\u0430\u043c\u043e\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 pg_dump<\/b><br \/>  \u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0428\u0442\u0430\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0412\u0441\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0432\u0435\u043b\u0438\u043a\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<br \/>  <b>\u041d\u043e<\/b>, \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. <br \/>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445-\u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043c\u043f\u043e\u0432.<br \/>  \u0412\u043e \u0432\u0442\u043e\u0440\u044b\u0445-\u0438 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0435, \u0431\u044b\u043b\u0438 \u0441\u043b\u0443\u0447\u0430\u0438 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0411\u0414 \u043f\u0440\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u0437 \u0434\u0430\u043c\u043f\u0430. <br \/>  \u0412 \u0442\u0440\u0435\u0442\u044c\u0438\u0445-\u0432\u0440\u0435\u043c\u044f, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0430\u043c\u043f\u0430, \u043f\u043e\u0442\u043e\u043c \u043d\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0411\u0414 \u0438\u0437 \u0434\u0430\u043c\u043f\u0430.<\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u0414 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438. \u0411\u0438\u0437\u043d\u0435\u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b, \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f. <br \/>  \u041d\u0435 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e\/\u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043e. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u044e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 PostgreSQL, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-323125","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=323125"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323125\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}