Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Txt files back-up

Author  Topic 

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 11:07:32
Hello friends,
i am not sure whether this is wright place of posting my query.

Every day 70 txt files comes into my server,this will be replaced with new text files the next day.

If my job fails i dont have any back-up storage of these files.

i am palnnning to create a back-up everyday for 40 txt files out of 70 and want to store in same location with folder naming with BACK-UP_TXT_FILES.

Guys,could you please let me know your ideas?

Thanx in Advance.







Satya

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-09-15 : 11:22:19
I'd set up a job to

1. Copy the files to a new location
2. Import the files
3. If import suceeds, delete the copied files
4. If it fails, send you an email and page you

This buys you an extra day to resolve any issues if the import fails.

Even better, keep a few days (maybe a weeks worth) before deleting the copies.
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 11:35:35
Thanx for ur reply,

At the movement these files download into the server on a nightly basis,current day files will be saved and previous day files will be deleted automatically.

Is ther any script to populate these files into new location before deleting.

Satya
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-09-15 : 12:05:19
can use windows copy (or xcopy) command. or robocopy.
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 17:34:53
thanx russel,

i am looking for a script that can do automatically every day after the downloading of txt files finishes,insetad of copying them manually.

Satya
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 18:05:52
Satya, run xcopy/robocopy via script. They are command line tools.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-09-15 : 18:21:52
exactly. make the step type Operating System Command. then just xcopy *.txt to the destination directory
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 18:39:07
Hi thanx both of u,

i think if i use that script all the files will be copied,is their any way other way to copy the selected txt files into new location instead of copying the complete files in the folder.

i need only 40 files out of 70txt files.

Thanx in advance.



Satya
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 18:46:04
Which 40 do you need? Programmatically, how can you tell the difference between the 40 that you need and the 30 that you don't?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 18:57:55
i got the list for the 40 files that need to back-up every day,becaz rest 30 are bulk files which are downloading every day.

my job is to skip bulk files and copy only ref txt files into back-up folder.

programmatically no idea , how to perform this task,looking for ideas from experts.

Satya
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 19:14:38
If you can't tell us how to differentiate them, then we can't code it for you.

If the file names don't change, then run one xcopy command per file. Otherwise, try to use a wildcard.

And if it needs to get fancy, then I'd highly recommend VBScript instead.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 19:34:11
all txt file name ends with _DATA_DAY.Txt

i have the below code
exec('cmd','copy D:\\Daily_Load\\'|| 'FILE_* D:\Daily_Load_back-up\\Archive',8);

i am trying to find more efficient code for taking back-up.

Satya
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 19:38:46
Use xcopy like this, substituting in your values: xcopy YourPath\*_DATA_DAY.Txt NewPath

What is inefficient with your current code? I am not familiar with that syntax, so I don't know what it's doing.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-15 : 19:46:32
thanx for ur help,
any way ill have a try with ur code.

with my code i can only do that with in my DI job.

Satya
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-16 : 05:35:14
hi,
when i used the below code in my job

xcopy R:\\ARI-DI-BO1\DATA_DAY\\ALERTS_DATA_DAY.Txt R:\\ARI-DI-BO1\DATA_DAY_ARCHIVE


it throwing an error message
[Script:Initialise]
(Ln 39) : Syntax error : near <R> found <IF> expecting <'(', '.'>


Guys,could you please if any changes required to the code.

Satya
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2010-09-16 : 09:50:18
It appears your path is incorrect. You're mixing a fixed drive (R:) and a network path name (\\ARI-DI-BOI...). It should be one or the other. I use network paths whenever possible as drive letters can/will change depending on which machine it executes from.

Terry

-- -- Everyone is entitled to be stupid, but some abuse the privilege.
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-09-16 : 10:30:36
Hi..
thanx to ur reply,

Now iam able to archive the file with this code
exec( 'cmd','copy \\\\emp_di_go1\\Reality\\DATA_DAY\SAL_DATA_DAY.TXT \\\\emp_di_go1\\Reality\\DATA_DAY_BACK_UP', 8 );

after copying the txt file into back-up folder i would like to rename with date extension(ex:SAL_DATA_DAY.TXT16092010)and for every month it should automaticallycreate a sub folder with that month name and all files should store in that month folder with date extension,this will be easy to trace the file.

could this possible?if possible what code should i add to my exec.

Thanx in advance.

Satya
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-16 : 12:27:44
Yes it's possible, and I'd suggest posting your question on a VBScript forum or a Windows forum.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -