?
Solved

pg_dump filename not correct in vista?

Posted on 2009-06-30
8
Medium Priority
?
786 Views
Last Modified: 2012-06-27
Hi,

Created a batch code that can backup postgre databases. The code is below. The output of the backup file in windows XP appears in this format:

<DbaseName>-<Year><MM><DD>-<HH><MM>.backup

e.g. mydatabase-20090629-1856.backup

However when tried in vista it appeared as:

mydatabase-062009-856.backup

The data for the filename is not appearing correctly in vista. Anyone who can tell me why is this happening and how can I correct the code so it will appear correctly in Vista?


Thanks.
@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 time=%time:~0,2%%time:~3,2%
   )
   set datestr=%year%%month%%day%-%time%
 
echo off    
   set BACKUP_FILE=<DBaseName>-%datestr%.backup
   set BIN_DIR="C:\Program Files\PostgreSQL\8.3\"
   SET PGPASSWORD=<POSTGREPASSWORD>
   
   %BIN_DIR%bin\pg_dump.exe -i -h <HostName> -p 5432 -U postgres -Fc -v -f %BACKUP_FILE% <DbaseName>

Open in new window

0
Comment
Question by:openaccount1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Author Comment

by:openaccount1
ID: 24743934
also, here is an erro that we are receiving.

Date Stamp for backu files is 062009-020 pg_dump too many command line arguments (first is "MyDbaseName" Try "pg_dump" help for more information.

0
 
LVL 3

Expert Comment

by:winstonep
ID: 24744888
It certainly appears that the date is being reported to the batch file differently in Vista. I'm not sure it's a good idea using batch files any more but I understand why as well.

Personally I would go for VBScript to take care of this but I'm afraid I don't know enough about it. Alternatively write a simple program in Visual BASIC perhaps?

I can only guess without having access to Vista here but how about trying  to re-arrange the order of the parameters or better still to debug, put a pause in and echo the contents of dow, day, year etc. to get an idea of what they actually contain.

Having said this, isn't there a backup option for the database that you can use instead? Don't know to be honest as I've only briefly tried this as I normally stick to Oracle, MySQL or SQL Server.
0
 
LVL 10

Assisted Solution

by:ivanovn
ivanovn earned 600 total points
ID: 24748438
I am running Vista Enterprise and your code works just fine. Are you sure you don't have any other code doing anything funny or an accidental comment/misspelling in the file you're using on Vista?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 22

Accepted Solution

by:
earth man2 earned 800 total points
ID: 24749590
you could have operating system default date format set differently.
0
 
LVL 3

Assisted Solution

by:winstonep
winstonep earned 600 total points
ID: 24749887
Yes true. The regional settings may be different in Vista so just check that you have them set to the same country and same date format.
0
 

Author Comment

by:openaccount1
ID: 24751457
Hi,

I am using the US format and the one running the code in Vista uses the UK format. Would that make a difference?
0
 

Author Closing Comment

by:openaccount1
ID: 31598286
Changed the  date to UK format and found the issue. The key codes are being designated differently when format of date is changed.
0
 
LVL 3

Expert Comment

by:winstonep
ID: 24752120
That would definitely make sense as all your formatting is doing is picking up the text in order from the date/time string rather than picking up the specific day/month/year
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question