?
Solved

Copy the file through script and file generation

Posted on 2014-02-27
17
Medium Priority
?
281 Views
Last Modified: 2014-03-04
Hi ...

OS Win 2008 R2 64bit.
I experienced some issues while settings up backup for PostgreSQL...found compatible issue. Finally decided to run script for copy the backup file with file generation.

I am good at script, request your help...

Backup.bak file store in local drive, location d:\data\back\backup.audit
I want to run the script which will copy the file everyday or weekly from the above location to D:\generation

I am looking for script which will copy the file in sequence with date and time it copy..also possible of having log file to know the file name change from source file to new file name with ddmmyyyyhhmmss.

Can you please help me....
0
Comment
Question by:Skumar_CCSA
[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
  • 12
  • 5
17 Comments
 
LVL 7

Accepted Solution

by:
vikas_madhusudana earned 2000 total points
ID: 39894151
@echo off
set datetimef=%date:~-4%_%date:~-7,2%_%date:~-10,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%
echo %datetime%
cp d:\data\back\backup.audit D:\generation\backup_%datetime%.audit

the above script creates out put in format  backup_2014_28_02_13_08_43.audit

you can then invoke the script from windows scheduler

http://windows.microsoft.com/en-in/windows/schedule-task#1TC=windows-7
0
 

Author Comment

by:Skumar_CCSA
ID: 39894187
thanks I will check and let you know soon.....
0
 
LVL 7

Expert Comment

by:vikas_madhusudana
ID: 39894478
Small correction it should be set datetime= instead of set datetimef= in second line
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:Skumar_CCSA
ID: 39897677
getting an error

---------------------------
Windows Script Host
---------------------------
Script:      F:\bac\move.vbs
Line:      1
Char:      1
Error:      Invalid character
Code:      800A0408
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------


@echo off
set datetime=%date:~-4%_%date:~-7,2%_%date:~-10,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%
echo %datetime%
cp f:\data\back\backup.audit f:\generation\backup_%datetime%.audit
0
 
LVL 7

Expert Comment

by:vikas_madhusudana
ID: 39898224
what i had given is batch script save it as mov.bat
0
 

Author Comment

by:Skumar_CCSA
ID: 39898261
I tried both ....    .bat and .vbs
It didn't work
0
 
LVL 7

Expert Comment

by:vikas_madhusudana
ID: 39898273
how are you running the script?
0
 
LVL 7

Expert Comment

by:vikas_madhusudana
ID: 39898275
I guess you should save the file as ANSI encoding as below (use nodepad) snapshot
0
 

Author Comment

by:Skumar_CCSA
ID: 39899888
i get below error now..


2014_03_03_17_26_54
'cp' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
0
 

Author Comment

by:Skumar_CCSA
ID: 39900053
@echo off
set datetime=%date:~-4%_%date:~-7,2%_%date:~-10,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%
echo %datetime%
copy "D:\Backup\from DB\backup.bak" "D:\Backup\to CommVault\backup_%datetime%.bak"

it worked finally....
change is required.
copy instead cp.
0
 

Author Comment

by:Skumar_CCSA
ID: 39902605
I've requested that this question be closed as follows:

Accepted answer: 300 points for vikas_madhusudana's comment #a39894151
Assisted answer: 100 points for vikas_madhusudana's comment #a39894478
Assisted answer: 0 points for Skumar_CCSA's comment #a39900053

for the following reason:

All three of worked for solution.
points shared...
0
 

Author Comment

by:Skumar_CCSA
ID: 39902133
this issue is resolved....
i gave points also...
want to close it...so that it will not list in my open question.
0
 

Author Comment

by:Skumar_CCSA
ID: 39902604
wrongly clicked close button while using iphone
0
 

Author Comment

by:Skumar_CCSA
ID: 39902606
wrongly clicked close button while using iphone
0
 

Author Comment

by:Skumar_CCSA
ID: 39902666
I've requested that this question be closed as follows:

Accepted answer: 450 points for vikas_madhusudana's comment #a39894151
Assisted answer: 25 points for vikas_madhusudana's comment #a39894478
Assisted answer: 0 points for Skumar_CCSA's comment #a39900053

for the following reason:

correct code.
0
 

Author Comment

by:Skumar_CCSA
ID: 39902609
correct code.....

@echo off
set datetime=%date:~-4%_%date:~-7,2%_%date:~-10,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%
echo %datetime%
copy "D:\Backup\from DB\backup.bak" "D:\Backup\to CommVault\backup_%datetime%.bak"
0
 

Author Closing Comment

by:Skumar_CCSA
ID: 39902667
your script worked well..
you also responded fast..
thanks to help.

little correction required.

copy d:\data\back\backup.audit D:\generation\backup_%datetime%.audit
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

A safe way to clean winsxs folder from your windows server 2008 R2 editions
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

765 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