{"id":130,"date":"2015-10-07T06:16:13","date_gmt":"2015-10-07T06:16:13","guid":{"rendered":"https:\/\/jongarrido.es\/?p=130"},"modified":"2015-10-07T06:16:13","modified_gmt":"2015-10-07T06:16:13","slug":"automated-postgresql-9-4-backup-on-windows","status":"publish","type":"post","link":"https:\/\/jongarrido.es\/?p=130","title":{"rendered":"Automated Postgresql 9.4 Backup on Windows"},"content":{"rendered":"<p>How to perform a dayly backup of a postgresql database on a windows server.<br \/>\n<!--more--><br \/>\nThis post it&#8217;s an update of this <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Automated_Backup_on_Windows\">one<\/a>. On this case this steps are refered to a 9.4 version of postgresql on a Windows Server 2012.<\/p>\n<p>In a new folder, for example d:\/pg_backup, you need to have the pg_dump.exe command available to run de . For this purpose you need to create a bin folder with the next libraries (and also pg_dump) inside :<\/p>\n<p><code>libeay32.dll<\/p>\n<p>libiconv-2.dll<\/p>\n<p>libintl-8.dll<\/p>\n<p>libpq.dll<\/p>\n<p>pg_dump.exe<\/p>\n<p>ssleay32.dll<\/p>\n<p>zlib1.dll<br \/>\n<\/code><\/p>\n<p>These files are available at your postgresql instalation folder C:\\path\\to\\posgresql-9.4\\bin<\/p>\n<p>Then you need to create a batch file in your d:\/pg_backup folder like this. You can name it as mydbbackup.bat.<\/p>\n<p><code>@echo off<br \/>\n   for \/f \"tokens=1-4 delims=\/ \" %%i in (\"%date%\") do (<br \/>\n     set dow=%%i<br \/>\n     set month=%%j<br \/>\n     set day=%%k<br \/>\n     set year=%%l<br \/>\n   )<br \/>\n   set datestr=%month%_%day%_%year%<br \/>\n   echo datestr is %datestr%<\/p>\n<p>   set BACKUP_FILE=<filename>_%datestr%.backup<br \/>\n   echo backup file name is %BACKUP_FILE%<br \/>\n   SET PGPASSWORD=<password>\n   echo on<br \/>\n   d:\\pg_backup\\bin\\pg_dump -i -h <host>-p 5432 -U <user>-F c -b -v -f %BACKUP_FILE% <dbname><\/code><\/p>\n<p>Here you must replece with your custom data: <code><filename>,<password>,<host><user><dbname><\/code>;.<\/p>\n<p>Then you can add a new task in your windows sheduled tasks to run this script dayly.<\/p>\n<p>&nbsp;<\/p>\n<p>That&#8217;s all<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to perform a dayly backup of a postgresql database on a windows server.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":0,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}