+ Post New Thread
Results 1 to 11 of 11
Windows Thread, Copy Batch file in Technical; Hey everyone, We have a program here that backs up files every hour and keeps all the backups for the ...
  1. #1
    Unvalidated User
    Join Date
    Apr 2008
    Location
    thetford
    Posts
    41
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Copy Batch file

    Hey everyone,

    We have a program here that backs up files every hour and keeps all the backups for the day.

    We have 7 databases that backup and we need the latest backup for those 7 to be copied into another once a day so we can run a daily backup of them.

    I am no good at writing Batch files, so was wonderin if someone knew what to type.

    For example, the files would be backing up to a folder on the E: drive called temp, and the latest backup for the 7 files need to be copied into the folder on E: called daily.

    Any help appreciated

  2. #2

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,308
    Thank Post
    242
    Thanked 1,589 Times in 1,266 Posts
    Rep Power
    344
    Code:
    @echo off
    XCOPY e:\temp\*.* e:\daily\ /Y
    exit
    Use Scheduled Tasks to schedule the date/time you want this to happen.

  3. #3
    BassTech's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    516
    Thank Post
    64
    Thanked 32 Times in 25 Posts
    Rep Power
    25
    We use this script for our VLE backup [edited]:

    Code:
    @echo off
    XCOPY E:\temp\*.* E:\daily\*.* /V /S /H /R /F /Y
    exit
    Copy & paste into notepad and save as "backup".bat then go to Start>All Programs>Accessories>System Tools>Scheduled Tasks and set "backup.bat" to run everyday
    Last edited by BassTech; 8th February 2010 at 03:36 PM.

  4. #4
    Unvalidated User
    Join Date
    Apr 2008
    Location
    thetford
    Posts
    41
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by Lee91 View Post
    We use this script for our VLE backup [edited]:

    Code:
    @echo off
    XCOPY E:\temp\*.* E:\daily\*.* /V /S /H /R /F /Y
    exit
    Copy & paste into notepad and save as "backup".bat then go to Start>All Programs>Accessories>System Tools>Scheduled Tasks and set "backup.bat" to run everyday


    it's copying across everything in that folder at the moment, need the last of those files

    files are named like this

    "backup 1 02-05-10 02-50-00PM"
    "backup 2 02-05-10 02-50-10PM"
    "backup 3 02-05-10 02-50-15PM"
    "backup 1 02-05-10 02-40-00PM"

    etc.

    What I need is for the batch file to grab the
    "backup 1 02-05-10 02-50-00PM"
    "backup 2 02-05-10 02-50-10PM"
    "backup 3 02-05-10 02-50-15PM"

    and leave the
    "backup 1 02-05-10 02-40-00PM" alone

  5. #5
    BassTech's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    516
    Thank Post
    64
    Thanked 32 Times in 25 Posts
    Rep Power
    25
    That's quite advanced for an xcopy command - Have a read about the /Exclude switch here - The Windows command Xcopy and its uses which you may be able to use with the /D switch maybe?

  6. #6

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,308
    Thank Post
    242
    Thanked 1,589 Times in 1,266 Posts
    Rep Power
    344
    Code:
    @echo off
    XCOPY e:\temp\backup 1 02-05-10 02-50-00PM.BKF e:\daily\ /Y
    XCOPY e:\temp\backup 2 02-05-10 02-50-10PM.BKF e:\daily\ /Y
    XCOPY e:\temp\backup 3 02-05-10 02-50-15PM.BKF e:\daily\ /Y
    XCOPY e:\temp\backup 1 02-05-10 02-40-00PM.BKF e:\daily\ /Y
    exit
    Maybe something like this as the *.* just means everything within that directory.

  7. #7
    BassTech's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    516
    Thank Post
    64
    Thanked 32 Times in 25 Posts
    Rep Power
    25
    Quote Originally Posted by Michael View Post
    Code:
    @echo off
    XCOPY e:\temp\backup 1 02-05-10 02-50-00PM.BKF e:\daily\ /Y
    XCOPY e:\temp\backup 2 02-05-10 02-50-10PM.BKF e:\daily\ /Y
    XCOPY e:\temp\backup 3 02-05-10 02-50-15PM.BKF e:\daily\ /Y
    XCOPY e:\temp\backup 1 02-05-10 02-40-00PM.BKF e:\daily\ /Y
    exit
    Maybe something like this as the *.* just means everything within that directory.
    Wont the file name change every day though? What about this:

    Code:
    @echo off
    XCOPY E:\temp\backup*15PM.* E:\daily\*.* /V /S /H /R /F /Y
    exit
    Not sure if that will work

  8. #8

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,308
    Thank Post
    242
    Thanked 1,589 Times in 1,266 Posts
    Rep Power
    344
    Yes, good point Lee91. The easiest option would be to backup that one file to 'Temp2' for example, so the *.* command could be used again.

  9. #9
    AXE
    AXE is offline
    AXE's Avatar
    Join Date
    Dec 2008
    Location
    Right here. Right Now.
    Posts
    200
    Thank Post
    188
    Thanked 56 Times in 19 Posts
    Rep Power
    23
    Run
    ATTRIB -A "E:\TEMP\BACKUP 1 *"
    ATTRIB -A "E:\TEMP\BACKUP 2 *" etc. before each hourly backup.

    After the backup, the only files with the 'archive' attribute set will be the most recent of each backup.

    Then XCOPY "E:\TEMP\*" "E:\DAILY\" /A /V /Y will only copy files with the 'archive' attribute set.

  10. #10
    BassTech's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    516
    Thank Post
    64
    Thanked 32 Times in 25 Posts
    Rep Power
    25
    Quote Originally Posted by AXE View Post
    Run
    ATTRIB -A "E:\TEMP\BACKUP 1 *"
    ATTRIB -A "E:\TEMP\BACKUP 2 *" etc. before each hourly backup.

    After the backup, the only files with the 'archive' attribute set will be the most recent of each backup.

    Then XCOPY "E:\TEMP\*" "E:\DAILY\" /A /V /Y will only copy files with the 'archive' attribute set.
    Nice, that should work

  11. #11
    Unvalidated User
    Join Date
    Apr 2008
    Location
    thetford
    Posts
    41
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Talking

    Quote Originally Posted by AXE View Post
    Run
    ATTRIB -A "E:\TEMP\BACKUP 1 *"
    ATTRIB -A "E:\TEMP\BACKUP 2 *" etc. before each hourly backup.

    After the backup, the only files with the 'archive' attribute set will be the most recent of each backup.

    Then XCOPY "E:\TEMP\*" "E:\DAILY\" /A /V /Y will only copy files with the 'archive' attribute set.
    Spot on, thank you very much, you have made me very happy



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 10
    Last Post: 26th October 2010, 05:50 PM
  2. Batch file to copy user profile
    By googlemad in forum Windows
    Replies: 2
    Last Post: 16th October 2010, 12:08 AM
  3. Batch File (select random file) help
    By fil_b in forum Windows Server 2000/2003
    Replies: 5
    Last Post: 5th November 2009, 05:13 AM
  4. Replies: 3
    Last Post: 5th May 2009, 04:00 PM
  5. Batch copy files and folders up one level
    By PrimaryTech in forum Windows
    Replies: 0
    Last Post: 13th March 2009, 10:28 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •