Can a file backup be appended to a copy in the destination folder

Status
Not open for further replies.

trunxson

New member
Local time
8:09 PM
Messages
20
I want to run a script as a bat file so it can be scheduled as a daily task. I think that ROBOCOPY is my best option but i cannot find suitable switches to make the script do what i want.

I want to copy "eventfile.txt" from a source to destination folder.
However, as this is a daily task, eventfile.txt will have a different text content each day (it is in fact my openvpn logfile) and after robocopy is run only the latest version of the file is copied to the destination, the previous day being overwritten.
What I want it to do is append eventfile.txt to the destination file so I can build a history of all my vpn events. None of the switches appear to allow me to do that.
Is there a workaround for this task or another way of doing this?
 

My Computer My Computer

At a glance

Windows7 32bit
OS
Windows7 32bit
It'll have to be a bit more complicated than a switch. The following batch file will rename each log file by adding the date and time of creation.

Code:
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" 
set "YY=%dt:~2,2%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" 
set "datestamp=%YY%%MM%%DD%"  
set "datafolder=WHEREVER YOUR LOG FILE TO BE COPIED IS" 
set "backupfolder=WHEREVER YOU WANT THE COPY TO GO\%datestamp%"  
set switches=/r:0 /w:0 /mir /ns /nc /ndl /np /njh /njs  robocopy %switches% "%datafolder%" "%backupfolder%"  
pause
 

My Computer My Computer

At a glance

windows 7 ultimate x64
Computer type
PC/Desktop
OS
windows 7 ultimate x64
That was just great. works as expected .
Thanks!
 

My Computer My Computer

At a glance

Windows7 32bit
OS
Windows7 32bit
Glad it worked! :)
 

My Computer My Computer

At a glance

windows 7 ultimate x64
Computer type
PC/Desktop
OS
windows 7 ultimate x64
Status
Not open for further replies.
Back
Top