<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>copy database &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/copy-database/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 04 Oct 2017 06:50:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: Copy Database to another Server in Windows (pg_dump &#8211; backup &#038; restore)</title>
		<link>https://www.dbrnd.com/2016/11/postgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool/</link>
					<comments>https://www.dbrnd.com/2016/11/postgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 24 Nov 2016 19:58:35 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[copy database]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[pg_dump]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[psql]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[server]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3907</guid>

					<description><![CDATA[In our organization, junior database developers are learning PostgreSQL, and they require a sample database from our Validation Database Server. In this scenario, Database Administrator takes PostgreSQL backup using pg_dump utility and restore that dump into the development environment. A pg_dump is a PostgreSQL utility which is used for PostgreSQL database backup and restore. Another [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&amp;linkname=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&amp;linkname=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&amp;linkname=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&amp;linkname=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&amp;linkname=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&amp;linkname=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool%2F&#038;title=PostgreSQL%3A%20Copy%20Database%20to%20another%20Server%20in%20Windows%20%28pg_dump%20%E2%80%93%20backup%20%26%20restore%29" data-a2a-url="https://www.dbrnd.com/2016/11/postgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool/" data-a2a-title="PostgreSQL: Copy Database to another Server in Windows (pg_dump – backup &amp; restore)"></a></p><p>In our organization, junior database developers are learning PostgreSQL, and they require a sample database from our Validation Database Server. </p>
<p>In this scenario, Database Administrator takes PostgreSQL backup using pg_dump utility and restore that dump into the development environment.</p>
<blockquote><p>A pg_dump is a PostgreSQL utility which is used for PostgreSQL database backup and restore. </p></blockquote>
<blockquote><p>Another option is, directly copy the database from one server to another server using pg_dump + psql. In this scenario, Database Administrator does not require any intermediate database backup file. </p></blockquote>
<p><em>Open your windows command prompt and go to \PostgreSQL\bin directory where you can execute and test below two different commands.<br />
</em></p>
<p><strong>Copy database from one server to another server (using, pg_dump | psql):</strong></p>
<pre class="crayon-plain-tag">pg_dump -h host1 dbname | psql -h host2 dbname</pre> </p>
<p><strong>Copy database, Using pg_dump utility for backup and restore:</strong></p>
<p><strong>Take full database backup:</strong></p>
<pre class="crayon-plain-tag">pg_dump -U username database_name &gt; filepath\backup.sql</pre> </p>
<p><strong>Restore database backup:</strong></p>
<pre class="crayon-plain-tag">pg_dump -U username database_name &lt; filepath\backup.sql</pre> </p>
<blockquote data-secret="89S6qFpLwG" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/09/postgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore/">PostgreSQL: File System Level Backup to just Copy DATA Directory</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/09/postgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore/embed/#?secret=89S6qFpLwG" data-secret="89S6qFpLwG" width="600" height="338" title="&#8220;PostgreSQL: File System Level Backup to just Copy DATA Directory&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/11/postgresql-copy-database-from-one-server-to-another-server-in-windows-pg_dump-utility-backup-restore-psql-tool/feed/</wfw:commentRss>
			<slash:comments>25</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Script to create a copy of the Existing Database</title>
		<link>https://www.dbrnd.com/2016/02/postgresql-script-to-create-a-copy-of-the-existing-database/</link>
					<comments>https://www.dbrnd.com/2016/02/postgresql-script-to-create-a-copy-of-the-existing-database/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 25 Feb 2016 19:59:23 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[copy database]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1804</guid>

					<description><![CDATA[IIn this post, I am sharing a script to make a copy of the PostgreSQL database. We can also create copies of the database using the pgAdmin tool, but I always preferred to use and create SQL script to perform the Database Administrator related activities. In the development environment, I am following a practice that [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&amp;linkname=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fpostgresql-script-to-create-a-copy-of-the-existing-database%2F&#038;title=PostgreSQL%3A%20Script%20to%20create%20a%20copy%20of%20the%20Existing%20Database" data-a2a-url="https://www.dbrnd.com/2016/02/postgresql-script-to-create-a-copy-of-the-existing-database/" data-a2a-title="PostgreSQL: Script to create a copy of the Existing Database"></a></p><p>IIn this post, I am sharing a script to make a copy of the PostgreSQL database. </p>
<p>We can also create copies of the database using the pgAdmin tool, but I always preferred to use and create SQL script to perform the Database Administrator related activities.  </p>
<blockquote><p>In the development environment, I am following a practice that after every release of the sprint, I take backup of the database and as well as create the previous version of the database. </p></blockquote>
<p>If any user wants to check existing functionality in the previous version, they can test with an old version of the database.</p>
<p><strong>Below is a script to make a copy of an existing database:</strong></p>
<pre class="crayon-plain-tag">CREATE DATABASE newDB WITH TEMPLATE oldDB OWNER dbUser;</pre> </p>
<p>After executing this,<br />
If you get any error, you should kill all the running sessions of that existing database.</p>
<pre class="crayon-plain-tag">ERROR:  source database "originaldb" is being accessed by other users</pre> </p>
<p><strong>You can use below script to kill all running sessions:</strong><br />
<strong><a href="https://www.dbrnd.com/2015/11/postgresql-script-to-kill-all-running-connections-and-sessions-of-a-database/" target="_blank">You can also visit this article</a>.</strong></p>
<pre class="crayon-plain-tag">SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE datname = 'datbase_name'
  AND pid &lt;&gt; pg_backend_pid();</pre>  </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/02/postgresql-script-to-create-a-copy-of-the-existing-database/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
