Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Simple back up via a batch file


  • Please log in to reply

#1
Woozer

Woozer

    New Member

  • Member
  • Pip
  • 2 posts
Hi Guys,

I've posted this under the XP part of the forum because I'm trying to create a simple back up batch file running on an XP machine.

Basically I have made a simple batch file that contains the following:-

del \\serv1\line_d\logs\log.txt
xcopy "c:\soundcheck 5.0\*.*" \\serv1\line_d\data /D /E /C /R /Y /F>\\serv1\line_d\logs\line_d.txt


which takes a look at the contents of my soundcheck folder and copies any new files to a server just as a precautionary back up. It also creates a little log file of what it has done.

This simple back up is fine for my needs as new files are always added to the source folder I'm backing up, but nothing is ever deleted.

What I would like to do now is enhance the logging of this process by keeping the logs created rather than delete the previous one. I'm not all that good at batch files (as you can probably see from the script I've created).

My idea is to move the log.txt file rather than delete, but I want to move the file and also rename it with the previous date in the file name (eg log_03032006.txt).

I know this won't work but I have tried typing:- move \\serv1\line_d\logs\log.txt log<date>.txt (don't laugh, if you don't try, you'll never know).

Please can anybody help with this?

Many thanks
Mike
  • 0

Advertisements


#2
dsenette

dsenette

    Je suis Napoléon!

  • Administrator
  • 26,046 posts
  • MVP
WOOOOHOOO>..i tried for 20 minutes for you and i got something promising

i had to change the way my system date was displayed...but i got it to work
changed the short date to this format M-d-yyyy and changed the seperator to -
then i did a test with the below syntax after creating a file named test1.txt in the c drive

ren c:\test1.txt "%date%.txt"

changed the file name to "Fri 03-03-2006.txt" (obviously..the file name didn't contain the " but you get the picture)
  • 0

#3
dsenette

dsenette

    Je suis Napoléon!

  • Administrator
  • 26,046 posts
  • MVP
so you'd end up with

ren \\serv1\line_d\logs\log.txt "%date%.txt"
xcopy "c:\soundcheck 5.0\*.*" \\serv1\line_d\data /D /E /C /R /Y /F>\\serv1\line_d\logs\log.txt

as long as you only do this once a day...you should be fine...haven;t been able to get it to work with the %time% function...but i'm working on it
(i changed taht from line_d.txt to log.txt as i assume that that's how you create the log...and that your original post was a typo...
  • 0

#4
dsenette

dsenette

    Je suis Napoléon!

  • Administrator
  • 26,046 posts
  • MVP
got the time to work...changed the time seperator from : to - in control panel and i got it to work with this

ren c:\test1.txt "%date%.txt" "%date% - %time%.txt"
file name ended up being "Fri 03-03-2006 - 12-53-27.96.txt"
  • 0

#5
Woozer

Woozer

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
Many thanks for your help!! This is something that has been bugging me for a few years, I've mastered it in AIX with using the set command. Yeah, did make a typo with line_d.txt.

This batch file runs once a day so should just be able to use the date part for the moment, but will keep hold of the time info you gave too.

Again thank you very much for the help.
Mike
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP