+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, Copy backups Script in Coding and Web Development; Hi there, I need some scripting help please. Every day one of the database servers backs up the databse files ...
  1. #1

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    45

    Copy backups Script

    Hi there,

    I need some scripting help please.

    Every day one of the database servers backs up the databse files to disk (on the server). The files are stored in folders called Daily_YYYY_MM_DD_2300 and it creates 7, one for each day of the week, and then overwites the oldest so I always have 7 folders.

    However I need to back them up to external storage somehow. I wanted to avoid having to delete and re-copy all the files due to slow network speeds. Basically I need to copy the newest backup folder from the source and delete the oldesst backup folder on the destination.

    any ideas?

  2. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    In the batch file delete the previous backup file / structure first using del, deltree or RD and then simply copy the new one into the folder.

    del d:\backups\monday\*.backup /q
    copy \\server\*.backup d:\monday

    Or delete the files from the backup source once copied over.

  3. Thanks to mattx from:

    Stuart_C (18th October 2012)

  4. #3

    jinnantonnixx's Avatar
    Join Date
    Mar 2011
    Location
    In the Calamatorium.
    Posts
    1,983
    Thank Post
    113
    Thanked 504 Times in 339 Posts
    Blog Entries
    2
    Rep Power
    286
    Robocopy with the /MIR option (mirror) will delete files on the destination that do not exist on the source.


    e.g. robocopy \\source\folder \\dest\folder * /mir

    Even though you specify the * wildcard, robocopy will not bother copying files that already exist on the destination.

    Robocopy | SS64.com


    /MIR : MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E)
    /PURGE : Delete dest files/folders that no longer exist in source.
    Last edited by jinnantonnixx; 2nd October 2012 at 02:44 PM.

  5. Thanks to jinnantonnixx from:

    Stuart_C (18th October 2012)

  6. #4

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    45
    Thanks @jinnantonnixx I'll give that a go.

  7. #5

    jinnantonnixx's Avatar
    Join Date
    Mar 2011
    Location
    In the Calamatorium.
    Posts
    1,983
    Thank Post
    113
    Thanked 504 Times in 339 Posts
    Blog Entries
    2
    Rep Power
    286
    Be careful - as with any powerful tool things can go wrong. The /MIR will delete everything that exists in the target that does not exist on the source.

    When testing, you might want to try the /L option, which does a dry run, without doing anything useful (or destructive).
    /L : List only - don’t copy, timestamp or delete any files.

SHARE:
+ Post New Thread

Similar Threads

  1. Rar archive with date backup script (.bat)
    By RabbieBurns in forum Scripts
    Replies: 1
    Last Post: 20th November 2009, 02:05 AM
  2. vmWare Backup Script (Server 2, Workstation, possibly ESX)
    By j17sparky in forum Thin Client and Virtual Machines
    Replies: 12
    Last Post: 31st July 2009, 01:29 PM
  3. Help with Backup Script
    By soze in forum Scripts
    Replies: 5
    Last Post: 18th June 2008, 12:12 AM
  4. SIMs backup script after SQL 2005 migration failing...
    By mullet_man in forum MIS Systems
    Replies: 13
    Last Post: 23rd November 2007, 06:03 PM
  5. Backup Script for NT backup and Robocopy
    By ChrisH in forum Scripts
    Replies: 12
    Last Post: 20th October 2005, 01:01 PM

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
  •