{"id":1629,"date":"2024-05-08T16:31:26","date_gmt":"2024-05-08T08:31:26","guid":{"rendered":"http:\/\/oneai.eu.org\/?p=1629"},"modified":"2024-05-08T16:31:26","modified_gmt":"2024-05-08T08:31:26","slug":"%e5%af%bc%e5%85%a5%e5%af%bc%e5%87%ba","status":"publish","type":"post","link":"https:\/\/oneai.eu.org\/?p=1629","title":{"rendered":"\u5bfc\u5165\u5bfc\u51fa"},"content":{"rendered":"<p>[root@M2M-DM_DB tscdb]# more  baktables.sh<br \/>\n# !\/usr\/bin\/bash<br \/>\nexport PGPASSWORD=dbpasswd<br \/>\ndate1=<code>date +&quot;20%y%m%d&quot;<\/code><br \/>\ncat tables.txt |while read table<br \/>\ndo<\/p>\n<p>pg<em>dump --host=&quot;172.21.38.22&quot; -U tscdba  -t ${table} tscdb  &gt; .\/${table}<\/em>${date1}.sql; <\/p>\n<p>sleep 1<br \/>\ndone<br \/>\npg_dump --host=&quot;172.21.38.22&quot; -U tscdba tscdb &gt; .\/tscdball-${date1}.sql;<br \/>\nexit<\/p>\n<hr \/>\n<p>[root@M2M-DM_DB tscdb]#  more importtables.sh<br \/>\n# !\/usr\/bin\/bash<br \/>\nexport PGPASSWORD=dbpasswd<br \/>\n#date1=<code>date +&quot;20%y%m%d&quot;<\/code><br \/>\ndate1=20160527<br \/>\ncat retables.txt |while read table<br \/>\ndo<\/p>\n<p>#pg<em>dump --host=&quot;10.47.104.96&quot; -U tscdba  -t ${table} tscdb  &gt; .\/${table}<\/em>${date1}.sql;<br \/>\npsql --host='172.21.38.22' -U tscdba -d tscdb &lt;.\/${table}_${date1}.sql;<br \/>\nsleep 1<br \/>\ndone<\/p>\n<hr \/>\n<p>\u6570\u636e\u5e93\u590d\u5236\uff1a<br \/>\nsu - postgres ;psql<\/p>\n<p>\u5148\u628a\u5f53\u524d\u5e93rename :<br \/>\nALTER DATABASE abc RENAME TO cba;<br \/>\n\u4ee5\u5df2\u7ecf\u6709\u7684\u6570\u636e\u5e93\uff0c\u4f5c\u4e3a\u6a21\u677f\uff0c\u7136\u540e\u8fd9\u77ac\u95f4\u5c31\u521b\u5efa\u597d\u4e86\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93.<br \/>\nCREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[root@M2M-DM_DB tscdb]# more baktables.sh # !\/usr\/bin\/bash export PGPASSWORD=dbpasswd date1=date +&quot;20%y%m%d&quot; cat tables.txt |while read table do pgdump &#8211;host=&quot;172.21.38.22&quot; -U tscdba -t ${table} tscdb &gt; .\/${table}${date1}.sql; sleep 1 done pg_dump &#8211;host=&quot;172.21.38.22&quot; -U tscdba tscdb &gt; .\/tscdball-${date1}.sql; exit [root@M2M-DM_DB tscdb]# more importtables.sh # !\/usr\/bin\/bash export PGPASSWORD=dbpasswd #date1=date +&quot;20%y%m%d&quot; date1=20160527 cat retables.txt |while read table do #pgdump &#8211;host=&quot;10.47.104.96&quot; -U tscdba -t ${table} tscdb &gt; .\/${table}${date1}.sql; psql &#8211;host=&#8217;172.21.38.22&#8242; -U tscdba -d tscdb &lt;.\/${table}_${date1}.sql; sleep 1 done \u6570\u636e\u5e93\u590d\u5236\uff1a su &#8211; postgres ;psql \u5148\u628a\u5f53\u524d\u5e93rename : ALTER DATABASE abc RENAME TO cba; \u4ee5\u5df2\u7ecf\u6709\u7684\u6570\u636e\u5e93\uff0c\u4f5c\u4e3a\u6a21\u677f\uff0c\u7136\u540e\u8fd9\u77ac\u95f4\u5c31\u521b\u5efa\u597d\u4e86\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93. CREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[89],"tags":[],"class_list":["post-1629","post","type-post","status-publish","format-standard","hentry","category-postgres-db"],"_links":{"self":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1629"}],"version-history":[{"count":1,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1629\/revisions"}],"predecessor-version":[{"id":1630,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1629\/revisions\/1630"}],"wp:attachment":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}