PostgreSQL, WIndows, regular backup

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PostgreSQL, WIndows, regular backup

Zlatko Matic
Hello.
I would appreciate if someone helps me to resolve this problem about regular backups on Windows. I have a batch file (.bat) for backup, but don't know how to include timestamp in backup file name. In this way I allways have only one, the most recent, backup file. I want Windows to produce regular backups with timestamp in file's name...The script is the following:
pg_dump -f D:\MYDB_BCP -Fc -x -h localhost -U postgres MYDB
How to include timestamp ?

 
 
Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL, WIndows, regular backup

SCassidy

This works to put the date in the filename on Windows 2000:

In a .bat file:


   @echo off
   for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
     set dow=%%i
     set month=%%j
     set day=%%k
     set year=%%l
   )
   set datestr=%month%_%day%_%year%
   echo datestr is %datestr%

   set BACKUP_FILE=MYDB_%datestr%
   echo backup file name is %BACKUP_FILE%

This creates a filename MYDB_mm_dd_yy.  When you run the little test .bat
script above, you will get:

datestr is 06_30_2005
backup file name is MYDB_06_30_2005

Hope this helps.
Susan


                                                                                                                                           
                           Zlatko Matić                                                                                                    
                      <[hidden email]-com        To:       <[hidden email]>                                              
                      .hr>                           cc:                                                                                  
                           Sent by:                  Subject:  [GENERAL] PostgreSQL, WIndows, regular backup                              
                                                                                                                                           
                                                      |-------------------|                                                                
                      pgsql-general-owner@pos         | [ ] Expand Groups |                                                                
                      tgresql.org                     |-------------------|                                                                
                                                                                                                                           
                                                                                                                                           
                           06/30/2005 09:52                                                                                                
                      AM                                                                                                                  
                                                                                                                                           
                                                                                                                                           




Hello.
I would appreciate if someone helps me to resolve this problem about
regular backups on Windows. I have a batch file (.bat) for backup, but
don't know how to include timestamp in backup file name. In this way I
allways have only one, the most recent, backup file. I want Windows to
produce regular backups with timestamp in file's name...The script is the
following:
pg_dump -f D:\MYDB_BCP -Fc -x -h localhost -U postgres MYDB
How to include timestamp ?









----------------------------------------------------------------------------------------------
See our award-winning line of tape and disk-based
backup & recovery solutions at http://www.overlandstorage.com
----------------------------------------------------------------------------------------------


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL, WIndows, regular backup

Zlatko Matic
It works great!
Thanks!

----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Thursday, June 30, 2005 7:45 PM
Subject: Re: [GENERAL] PostgreSQL, WIndows, regular backup



This works to put the date in the filename on Windows 2000:

In a .bat file:


   @echo off
   for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
     set dow=%%i
     set month=%%j
     set day=%%k
     set year=%%l
   )
   set datestr=%month%_%day%_%year%
   echo datestr is %datestr%

   set BACKUP_FILE=MYDB_%datestr%
   echo backup file name is %BACKUP_FILE%

This creates a filename MYDB_mm_dd_yy.  When you run the little test .bat
script above, you will get:

datestr is 06_30_2005
backup file name is MYDB_06_30_2005

Hope this helps.
Susan



                           Zlatko Matić
                      <[hidden email]-com        To:
<[hidden email]>
                      .hr>                           cc:
                           Sent by:                  Subject:  [GENERAL]
PostgreSQL, WIndows, regular backup

                                                      |-------------------|
                      pgsql-general-owner@pos         | [ ] Expand Groups |
                      tgresql.org                     |-------------------|


                           06/30/2005 09:52
                      AM






Hello.
I would appreciate if someone helps me to resolve this problem about
regular backups on Windows. I have a batch file (.bat) for backup, but
don't know how to include timestamp in backup file name. In this way I
allways have only one, the most recent, backup file. I want Windows to
produce regular backups with timestamp in file's name...The script is the
following:
pg_dump -f D:\MYDB_BCP -Fc -x -h localhost -U postgres MYDB
How to include timestamp ?









----------------------------------------------------------------------------------------------
See our award-winning line of tape and disk-based
backup & recovery solutions at http://www.overlandstorage.com
----------------------------------------------------------------------------------------------


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend