{"id":1871,"date":"2016-10-17T17:15:00","date_gmt":"2016-10-17T14:15:00","guid":{"rendered":"http:\/\/www.systemcodegeeks.com\/?p=1871"},"modified":"2017-12-04T16:07:35","modified_gmt":"2017-12-04T14:07:35","slug":"postgresql-backup-restore-migration","status":"publish","type":"post","link":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/","title":{"rendered":"PostgreSQL backup, restore, and migration Tutorial"},"content":{"rendered":"<p><em>This article is part of our Academy Course titled <a href=\"http:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-database-tutorial\/\">PostgreSQL Database Tutorial<\/a>.<\/p>\n<p>In this course, we provide a compilation of PostgreSQL tutorials that will help you set up and run your own database management system. We cover a wide range of topics, from installation and configuration, to custom commands and datatypes. With our straightforward tutorials, you will be able to get your own projects up and running in minimum time. Check it out <a href=\"http:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-database-tutorial\/\">here<\/a>!<\/em><\/p>\n<p>Since hardware can fail and human error may occur, having frequent backups and knowing how to restore them are important skills that every system administrator should have. Additionally, you will need to know how to migrate PostgreSQL databases from one machine to another in case you purchase new, more powerful servers. Thus, in this tutorial we will discuss how to perform these critical operations using a test environment with two Ubuntu 16.04 (server edition) virtual machines. We will name these VMs <em><strong>newserver<\/strong><\/em> (192.168.0.54) and <em><strong>oldserver<\/strong><\/em> (192.168.0.55), where the same PostgreSQL version (9.5) has been installed on both. We assume we will migrate the World_db database on <strong>oldserver<\/strong> over to <strong>newserver<\/strong>.<br \/>\n[ulp id=&#8217;mezv5fambxsNcQw8&#8242;]<\/p>\n<h2>1. Backup, restore, and migration strategies<\/h2>\n<p>Traditionally, PostgreSQL database administrators used shell scripts and cron jobs to back up their databases. Although this approach was considered efficient a decade (or so) ago, today there are tools that make this process hassle-free and easier to maintain. Among these tools, Barman (Backup and Recovery Manager), a Python-based open source solution developed and maintained by <a href=\"http:\/\/www.pgbarman.org\/\" target=\"_blank\">2ndQuadrant<\/a> (a firm that specializes in PostgreSQL services) stands out.<\/p>\n<h2>2. Installing Barman<\/h2>\n<p>More accurately, Barman is a backup, restore, and disaster recovery tool for PostgreSQL. We will install it on the virtual machine that we called <strong>newserver<\/strong> (192.168.0.54) to migrate the databases from <strong>oldserver<\/strong> (192.168.0.55).<\/p>\n<p>That said, let&#8217;s install Barman:<\/p>\n<pre class=\"brush:bash\">sudo aptitude update &amp;&amp; sudo aptitude install barman<\/pre>\n<p>Once the installation has completed successfully, proceed with the following steps.<\/p>\n<h3>Step 1 &#8211; Create a dedicated PostgreSQL user in oldserver<\/h3>\n<p>In order for barman (which has been installed in <strong>newserver<\/strong>) to communicate with the PostgreSQL instance running on <strong>oldserver<\/strong>, we need to create a dedicated database user. To do so, run the following command as <strong>postgres<\/strong> on <strong>oldserver<\/strong> and enter the desired password for the new database user. Also, when you&#8217;re prompted to confirm if the account should have superuser privileges, enter y and press Enter<\/p>\n<pre class=\"brush:bash\">createuser --interactive -P barman<\/pre>\n<p>Then test the connection from <strong>newserver<\/strong>. We will check the connection against the postgres database, but you can use other database (in that case, you&#8217;ll have to modify the SQL query inside single quotes):<\/p>\n<pre class=\"brush:bash\">psql -c 'SELECT version()' -U barman -h 192.168.0.55 postgres<\/pre>\n<p>Refer to Fig. 1 for details:<\/p>\n<figure id=\"attachment_1878\" aria-describedby=\"caption-attachment-1878\" style=\"width: 668px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_238.png\"><img decoding=\"async\" class=\"size-full wp-image-1878\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_238.png\" alt=\"Creating a dedicated user account and testing the connection\" width=\"668\" height=\"468\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_238.png 668w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_238-300x210.png 300w\" sizes=\"(max-width: 668px) 100vw, 668px\" \/><\/a><figcaption id=\"caption-attachment-1878\" class=\"wp-caption-text\">Figure 1 &#8211; Creating a dedicated user account and testing the connection<\/figcaption><\/figure>\n<div class=\"tip\">Throughout this article, we will use the word Barman to refer to the program itself, whereas the all-lowercase <em>barman<\/em> will represent either the command associated with the program or an account.<\/div>\n<h3>Step 2 &#8211; Create the .pgpass file in newserver<\/h3>\n<p>As part of the installation of Barman on <strong>newserver<\/strong>, a Linux account called <em>barman<\/em> was created. To set its password, do<\/p>\n<pre class=\"brush:bash\">sudo passwd barman<\/pre>\n<p>and enter the desired password. Then, switch user to barman:<\/p>\n<pre class=\"brush:bash\">sudo -i -u barman<\/pre>\n<p>and create the .pgpass file for user barman:<\/p>\n<pre class=\"brush:bash\">echo \"192.168.0.55:5432:*:barman:password\" &gt;&gt; ~\/.pgpass<\/pre>\n<div class=\"tip\">The actual format for the .pgpass file is <em>hostname:port:database:username:password<\/em>. If an asterisk is used in any of the first four fields, it will match everything. Please note that <em>username<\/em> here represents the PostgreSQL user we created in Step 1, not the Linux account we just referred to. The official documentation for this file can be found <a href=\"https:\/\/www.postgresql.org\/docs\/current\/static\/libpq-pgpass.html\" target=\"_blank\">here<\/a>.<\/div>\n<p>This file can contain passwords to be used if a connection requires one (in this case, barman will use it to talk to the PostgreSQL instance on <strong>oldserver<\/strong>).<\/p>\n<h3>Step 3 &#8211; Set up key-based authentication<\/h3>\n<p>In order to perform backups without user intervention we will need to set up and copy SSH keys for passwordless authentication. Barman will make use of this method to copy data through rsync.<\/p>\n<p>On <strong>newserver<\/strong>, switch to user barman and generate the keys<\/p>\n<pre class=\"brush:bash\">ssh-keygen -t rsa<\/pre>\n<p>(choose the default destination file for the public key and an empty passphrase).<\/p>\n<p>Next, copy the public key to the authorized keys of user postgres on <strong>oldserver<\/strong>:<\/p>\n<pre class=\"brush:bash\">ssh-copy-id postgres@192.168.0.55<\/pre>\n<p>This will allow <em>barman<\/em> on <strong>newserver<\/strong> to connect to <strong>oldserver<\/strong> as user <em>postgres<\/em>.\u00a0To test if the connection can be made without password, as expected, you can run the following command (on success, it will not return anything):<\/p>\n<pre class=\"brush:bash\">ssh postgres@192.168.0.55 -C true<\/pre>\n<p>You&#8217;ll also need to allow barman to SSH into localhost as the local user <em>postgres<\/em>:<\/p>\n<pre class=\"brush:bash\">ssh-copy-id postgres@localhost\r\nssh postgres@localhost -C true<\/pre>\n<p>Finally, on <strong>oldserver<\/strong> log in as <em>postgres<\/em> and do<\/p>\n<pre class=\"brush:bash\">ssh-keygen -t rsa<\/pre>\n<p>and copy the resulting key to the list of authorized keys for user barman on newserver:<\/p>\n<pre class=\"brush:bash\">ssh-copy-id barman@192.168.0.54<\/pre>\n<p>Again, test the connection before proceeding:<\/p>\n<pre class=\"brush:bash\">ssh barman@192.168.0.54 -C true<\/pre>\n<h3>Step 4 &#8211; Configure Barman<\/h3>\n<p>On <strong>newserver<\/strong>, open the Barman main configuration file (\/etc\/barman.conf) and uncomment this line by removing the leading semicolon:<\/p>\n<pre class=\"brush:bash\">;configuration_files_directory = \/etc\/barman.d<\/pre>\n<p>should read<\/p>\n<pre class=\"brush:bash\">configuration_files_directory = \/etc\/barman.d<\/pre>\n<p>(if \/etc\/barman.d does not exist, you&#8217;ll have to create it with <code>mkdir \/etc\/barman.d<\/code>)<\/p>\n<p>And create a file named oldserver.conf with the following contents (the word inside square brackets represents the name that barman will use to identify the connection details):<\/p>\n<pre class=\"brush:bash\">[oldserver]\r\ndescription =\u00a0 \"Our old PostgreSQL server\"\r\nconninfo = host=192.168.0.55 user=barman dbname=World_db\r\nssh_command = ssh postgres@192.168.0.55\r\nretention_policy = RECOVERY WINDOW OF 2 WEEKS<\/pre>\n<p>where most variables are self-explanatory with the exception of <strong>retention_policy<\/strong>. This variable is used to determine for how long backups should be kept (2 weeks in this case). This should be modified based on the expected activity and growth of the database, and the available space on the filesystem where backups will be kept.<\/p>\n<h3>Step 5 &#8211; Configure PostgreSQL<\/h3>\n<p>On <strong>oldserver<\/strong>:<\/p>\n<p>Add this line to \/etc\/postgresql\/9.5\/main\/pg_hba.conf:<\/p>\n<pre class=\"brush:bash\">host\u00a0\u00a0\u00a0 all\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 all\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 192.168.0.54\/24\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 trust<\/pre>\n<p>Then make sure the following variables on \/etc\/postgresql\/9.5\/main\/postgresql.conf have the indicated values:<\/p>\n<pre class=\"brush:bash\">wal_level = archive\r\narchive_mode = on\r\narchive_command = 'rsync -a %p barman@192.168.0.54:\/var\/lib\/barman\/oldserver\/incoming\/%f'<\/pre>\n<div class=\"tip\">As you will probably guess, the directory in the rsync connection string represents the directory where the backup files for <strong>oldserver<\/strong> will be kept on <strong>newserver<\/strong>.<\/div>\n<p>On <strong>newserver<\/strong>, make sure the following variable on \/etc\/postgresql\/9.5\/main\/postgresql.conf has the indicated value:<\/p>\n<pre class=\"brush:bash\">data_directory = '\/var\/lib\/postgresql\/9.5\/data'<\/pre>\n<p>If the directory called <strong>data<\/strong> does not exist under \/var\/lib\/postgresql\/9.5, create it before proceeding (that is where the data files will be stored on newserver)<\/p>\n<p>Then restart the postgresql service to activate the latest changes:<\/p>\n<pre class=\"brush:bash\">sudo systemctl restart postgresql<\/pre>\n<h3>Step 6 &#8211; Test the Barman configuration<\/h3>\n<p>Once PostgreSQL has been configured on <strong>oldserver<\/strong> to allow connections from newserver, we are ready to test the configuration. To do so, switch to user barman on newserver and do<\/p>\n<pre class=\"brush:bash\">barman check oldserver\r\nbarman list-server<\/pre>\n<p>The first command will check the SSH and PostgreSQL connections, whereas the second one will show the list of configured PostgreSQL servers we wish to back up.<\/p>\n<p>The output should be as follows (see Fig. 2):<\/p>\n<figure id=\"attachment_1880\" aria-describedby=\"caption-attachment-1880\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_240.png\"><img decoding=\"async\" class=\"size-full wp-image-1880\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_240.png\" alt=\"Checking the barman connection from newserver to oldserver\" width=\"654\" height=\"277\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_240.png 654w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_240-300x127.png 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/a><figcaption id=\"caption-attachment-1880\" class=\"wp-caption-text\">Figure 2 &#8211; Checking the barman connection from newserver to oldserver<\/figcaption><\/figure>\n<h3>Step 7 &#8211; Perform the backup<\/h3>\n<p>Once all of the items in the output of <code>barman check oldserver<\/code> return OK, we are ready to perform our first backup with the following command (see Fig. 3):<\/p>\n<pre class=\"brush:bash\">barman backup oldserver<\/pre>\n<p>The output should be similar to Fig. 3:<\/p>\n<figure id=\"attachment_1879\" aria-describedby=\"caption-attachment-1879\" style=\"width: 485px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_239.png\"><img decoding=\"async\" class=\"size-full wp-image-1879\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_239.png\" alt=\"Creating our first backup with barman\" width=\"485\" height=\"180\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_239.png 485w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_239-300x111.png 300w\" sizes=\"(max-width: 485px) 100vw, 485px\" \/><\/a><figcaption id=\"caption-attachment-1879\" class=\"wp-caption-text\">Figure 3 &#8211; Creating our first backup with barman<\/figcaption><\/figure>\n<p>Once the backup has completed we can identify it with the help of<\/p>\n<pre class=\"brush:bash\">barman list-backup oldserver<\/pre>\n<p>which will list all the backups we have performed for oldserver. To view details about a specific backup, we&#8217;ll use<\/p>\n<pre class=\"brush:bash\">barman show-backup oldserver backup_id<\/pre>\n<p>where <em>backup_id<\/em> is the backup identification (<strong>20161015T120420<\/strong> in Fig. 4).<\/p>\n<figure id=\"attachment_1881\" aria-describedby=\"caption-attachment-1881\" style=\"width: 566px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_241.png\"><img decoding=\"async\" class=\"size-full wp-image-1881\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_241.png\" alt=\"Checking backups\" width=\"566\" height=\"423\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_241.png 566w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_241-300x224.png 300w\" sizes=\"(max-width: 566px) 100vw, 566px\" \/><\/a><figcaption id=\"caption-attachment-1881\" class=\"wp-caption-text\">Figure 4 &#8211; Checking backups<\/figcaption><\/figure>\n<h3>Step 8 &#8211; Restore the backup on newserver<\/h3>\n<p>As we can see in Fig. 8, the World_db database can&#8217;t be found on <strong>newserver<\/strong>. To migrate a backup, we will stop the postgresql service<\/p>\n<pre class=\"brush:bash\">sudo systemctl stop postgresql<\/pre>\n<p>and run the following command as user <em>barman<\/em>:<\/p>\n<pre class=\"brush:bash\">barman recover --remote-ssh-command \"ssh postgres@localhost\" oldserver 20161015T142346 \/var\/lib\/postgresql\/9.5\/data<\/pre>\n<p>Note how barman makes use of the SSH keys to connect as user <em>postgres<\/em> to localhost in order to load the backup with id\u00a0<strong>20161015T142346<\/strong> to the data directory. The result is shown in Fig. 5:<\/p>\n<figure id=\"attachment_1890\" aria-describedby=\"caption-attachment-1890\" style=\"width: 660px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_244.png\"><img decoding=\"async\" class=\"size-full wp-image-1890\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_244.png\" alt=\"Restoring a backup with barman\" width=\"660\" height=\"345\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_244.png 660w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_244-300x157.png 300w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a><figcaption id=\"caption-attachment-1890\" class=\"wp-caption-text\">Figure 5 &#8211; Restoring a backup with barman<\/figcaption><\/figure>\n<p>After the recovery or migration is complete, start the postgresql service with a user with sudo access<\/p>\n<pre class=\"brush:bash\">sudo systemctl start postgresql<\/pre>\n<p>and check the World_db database as user <em>postgres<\/em>:<\/p>\n<pre class=\"brush:bash\">sudo -i -u postgres\r\npsql\r\n\\c World_db<\/pre>\n<p>Now let&#8217;s run queries against the database, as shown in Fig. 6:<\/p>\n<figure id=\"attachment_1891\" aria-describedby=\"caption-attachment-1891\" style=\"width: 520px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_245.png\"><img decoding=\"async\" class=\"size-full wp-image-1891\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_245.png\" alt=\"Querying the database we migrated\" width=\"520\" height=\"258\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_245.png 520w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/10\/Selection_245-300x149.png 300w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/a><figcaption id=\"caption-attachment-1891\" class=\"wp-caption-text\">Figure 6 &#8211; Querying the database we migrated<\/figcaption><\/figure>\n<p>Congratulations! You have successfully set up a very effective method to back up, restore, and migrate PostgreSQL databases.<\/p>\n<h2>3. Automating backups<\/h2>\n<p>In order to automate the backup process, switch to user barman and open the crontab file:<\/p>\n<pre class=\"brush:bash\">sudo -i -u barman\r\ncrontab -e<\/pre>\n<p>Then add the following two lines in it in order to execute a backup of oldserver each day at 12:45 pm<\/p>\n<pre class=\"brush:bash\">45 12 * * * \/usr\/bin\/barman backup oldserver<\/pre>\n<p>Please note that this is a basic Barman \/ PostgreSQL setup, so I strongly suggest to check the official Barman docs <a href=\"http:\/\/www.pgbarman.org\/documentation\/\" target=\"_blank\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will help you set up and run your own database management system. We cover a wide range of topics, from installation and configuration, to custom commands and datatypes. With our straightforward tutorials, &hellip;<\/p>\n","protected":false},"author":15,"featured_media":198,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1871","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PostgreSQL backup, restore, and migration Tutorial - System Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL backup, restore, and migration Tutorial - System Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\" \/>\n<meta property=\"og:site_name\" content=\"System Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/systemcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/gacanepa\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-17T14:15:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-04T14:07:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Gabriel Canepa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@gacanepa\" \/>\n<meta name=\"twitter:site\" content=\"@systemcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gabriel Canepa\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\"},\"author\":{\"name\":\"Gabriel Canepa\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/967da353d0f1a1de21c9504942625a5f\"},\"headline\":\"PostgreSQL backup, restore, and migration Tutorial\",\"datePublished\":\"2016-10-17T14:15:00+00:00\",\"dateModified\":\"2017-12-04T14:07:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\"},\"wordCount\":1421,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg\",\"articleSection\":[\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\",\"url\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\",\"name\":\"PostgreSQL backup, restore, and migration Tutorial - System Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg\",\"datePublished\":\"2016-10-17T14:15:00+00:00\",\"dateModified\":\"2017-12-04T14:07:35+00:00\",\"description\":\"This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will\",\"breadcrumb\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage\",\"url\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg\",\"contentUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.systemcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Databases\",\"item\":\"https:\/\/www.systemcodegeeks.com\/category\/databases\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL\",\"item\":\"https:\/\/www.systemcodegeeks.com\/category\/databases\/postgresql\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"PostgreSQL backup, restore, and migration Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#website\",\"url\":\"https:\/\/www.systemcodegeeks.com\/\",\"name\":\"System Code Geeks\",\"description\":\"Operating System Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.systemcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.systemcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/systemcodegeeks\",\"https:\/\/x.com\/systemcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/967da353d0f1a1de21c9504942625a5f\",\"name\":\"Gabriel Canepa\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/27b3ea2a3fb1de4ed1c8694a1465c099a86586d8b833a0d852a26d76d750df9f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/27b3ea2a3fb1de4ed1c8694a1465c099a86586d8b833a0d852a26d76d750df9f?s=96&d=mm&r=g\",\"caption\":\"Gabriel Canepa\"},\"description\":\"Gabriel Canepa is a Linux Foundation Certified System Administrator (LFCS-1500-0576-0100) and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work. When he's not typing commands or writing code or articles, he enjoys telling bedtime stories with his wife to his two little daughters and playing with them, the great pleasure of his life.\",\"sameAs\":[\"http:\/\/www.gabrielcanepa.com.ar\/\",\"https:\/\/www.facebook.com\/gacanepa\",\"https:\/\/ar.linkedin.com\/in\/gacanepa\",\"https:\/\/x.com\/gacanepa\"],\"url\":\"https:\/\/www.systemcodegeeks.com\/author\/gabriel-canepa\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL backup, restore, and migration Tutorial - System Code Geeks - 2026","description":"This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL backup, restore, and migration Tutorial - System Code Geeks - 2026","og_description":"This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will","og_url":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/","og_site_name":"System Code Geeks","article_publisher":"https:\/\/www.facebook.com\/systemcodegeeks","article_author":"https:\/\/www.facebook.com\/gacanepa","article_published_time":"2016-10-17T14:15:00+00:00","article_modified_time":"2017-12-04T14:07:35+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg","type":"image\/jpeg"}],"author":"Gabriel Canepa","twitter_card":"summary_large_image","twitter_creator":"@gacanepa","twitter_site":"@systemcodegeeks","twitter_misc":{"Written by":"Gabriel Canepa","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#article","isPartOf":{"@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/"},"author":{"name":"Gabriel Canepa","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/967da353d0f1a1de21c9504942625a5f"},"headline":"PostgreSQL backup, restore, and migration Tutorial","datePublished":"2016-10-17T14:15:00+00:00","dateModified":"2017-12-04T14:07:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/"},"wordCount":1421,"commentCount":2,"publisher":{"@id":"https:\/\/www.systemcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg","articleSection":["PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/","url":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/","name":"PostgreSQL backup, restore, and migration Tutorial - System Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.systemcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage"},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg","datePublished":"2016-10-17T14:15:00+00:00","dateModified":"2017-12-04T14:07:35+00:00","description":"This article is part of our Academy Course titled PostgreSQL Database Tutorial. In this course, we provide a compilation of PostgreSQL tutorials that will","breadcrumb":{"@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#primaryimage","url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg","contentUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/postgresql-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.systemcodegeeks.com\/databases\/postgresql\/postgresql-backup-restore-migration\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.systemcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Databases","item":"https:\/\/www.systemcodegeeks.com\/category\/databases\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL","item":"https:\/\/www.systemcodegeeks.com\/category\/databases\/postgresql\/"},{"@type":"ListItem","position":4,"name":"PostgreSQL backup, restore, and migration Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.systemcodegeeks.com\/#website","url":"https:\/\/www.systemcodegeeks.com\/","name":"System Code Geeks","description":"Operating System Developers Resource Center","publisher":{"@id":"https:\/\/www.systemcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.systemcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.systemcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.systemcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/systemcodegeeks","https:\/\/x.com\/systemcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/967da353d0f1a1de21c9504942625a5f","name":"Gabriel Canepa","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/27b3ea2a3fb1de4ed1c8694a1465c099a86586d8b833a0d852a26d76d750df9f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/27b3ea2a3fb1de4ed1c8694a1465c099a86586d8b833a0d852a26d76d750df9f?s=96&d=mm&r=g","caption":"Gabriel Canepa"},"description":"Gabriel Canepa is a Linux Foundation Certified System Administrator (LFCS-1500-0576-0100) and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work. When he's not typing commands or writing code or articles, he enjoys telling bedtime stories with his wife to his two little daughters and playing with them, the great pleasure of his life.","sameAs":["http:\/\/www.gabrielcanepa.com.ar\/","https:\/\/www.facebook.com\/gacanepa","https:\/\/ar.linkedin.com\/in\/gacanepa","https:\/\/x.com\/gacanepa"],"url":"https:\/\/www.systemcodegeeks.com\/author\/gabriel-canepa\/"}]}},"_links":{"self":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts\/1871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/comments?post=1871"}],"version-history":[{"count":0,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts\/1871\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/media\/198"}],"wp:attachment":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/media?parent=1871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/categories?post=1871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/tags?post=1871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}