Ask Experts Questions for FREE Help !
Ask
    chedmeister's Avatar
    chedmeister Posts: 4, Reputation: 1
    New Member
     
    #1

    Jul 29, 2007, 10:12 AM
    The foolproof backup batch file!
    Hi, hope this is the right place to ask about windows XP dos batch files.

    I fix home PCs for a living and want to make a foolproof backup procedure that runs overnight. I want the user to plug in a USB drive Thursday eve and take it away on Friday with the backup files on it.

    Im using Acronis home for the actual backup and it makes backup files with a .tib format.
    Acronis can be asked to run a batch file after it finishes its backup job.

    I want the batch file to:
    Make a new folder with todays date as the title on the USB drive.
    Move the .tib file to the new folder.

    The new folder name must be unique as they may have multiple backups on the USB drive.
    The date should be in a DD-MM-YYYY format (may be easier to leave out the separators)

    The problem is getting dos to create a folder with today's date as the name. Ive seen a few suggestions on the net from a chap named 'seamonkey' but I'm only so good with dos.

    Please help, this will make me look really clever :D and hopefully will be a quick one for a dos wizz.
    benn11's Avatar
    benn11 Posts: 1,036, Reputation: 43
    Ultra Member
     
    #2

    Jul 30, 2007, 04:21 AM
    What have you come up with so far?
    chedmeister's Avatar
    chedmeister Posts: 4, Reputation: 1
    New Member
     
    #3

    Jul 30, 2007, 10:38 AM
    So far I have this. I don't take credit cos I pinched it from another site:

    echo on
    FOR /F "TOKENS=1,2 DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
    FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('DATE/T') DO SET dd=%%B
    FOR /F "TOKENS=3,4 DELIMS=/ " %%A IN ('DATE/T') DO SET yy=%%B
    echo mm is: %mm%"dd is:"%dd%yy is %yy%
    set Pdate=%mm%.%dd%.%yy%
    echo %Pdate%

    Ren C:\backup\new %Pdate%

    This renames the folder with the month and the year but I need the day as well.
    preferably in DD.MM.YYYY format.

    I also found this:

    echo on
    set Pdate=%date:~3,2%.%date:~0,2%.%date:~-2,2%
    echo %Pdate%

    Ren C:\backup\new %Pdate%

    Which also does the same thing but masterfully shortened.
    Either one is fine but I just need the day shown.

    Just for the record I have tried to understand the script and adapt it more myself but I've not had the training in advanced DOS. :(
    chedmeister's Avatar
    chedmeister Posts: 4, Reputation: 1
    New Member
     
    #4

    Jul 30, 2007, 04:36 PM
    Ive just realised that this may not make any sense to you because it will work for you in America but I always get 07.2007. I've tried fiddling with the code but I can't get it to show all three parts of the date. If I change the date format in my regional settings I get 31.2007 so its not like its not able to collect the info properly. It just won't use what its got to write it in the way that I want.
    Don't understand why this is. Is it a bug in dos or something? :confused:
    chedmeister's Avatar
    chedmeister Posts: 4, Reputation: 1
    New Member
     
    #5

    Sep 7, 2007, 04:31 AM
    I actually found help for this on another site so id like to just wrap this up for anyone else who might be doing this in the future.

    I am now using the following batch file which seems to be working well in clients machines.
    Acronis runs this batch file once its finished doing its backup. I have included some reminders in there so I hope they make sense.

    ECHO on

    @REM Copy contents of premade C:\backup\new folder to the 'Backups' folder on the removable drive.

    @REM /v verifies each file that is copied * /h copies hidden and attributed files
    Cd C:\

    XCOPY backup (insert removable drive letter here):\Backups\ /s /h /v

    @REM Rename the folder with today's date. To make sure this works on any PC you may have
    @REM to adapt this next bit. In dos type and examine 'echo %date%'. To make the 3 groups of
    @REM count how many characters along the first character you want to show is.
    @REM So for the day it will be '0' characters. Then choose how many characters after that
    @REM you want to show. You want 2 characters so choose '2'. This last bit changes for the
    @REM year dcepending on if you want to show 2 or 4 characters.

    SET Pdate=%date:~0,2%.%date:~3,2%.%date:~6,4%
    ECHO %Pdate%

    REN (insert removable drive letter here):\Backups\new %Pdate%

    @REM The next bit deletes any files in the backup folder on the C:\ root, leaving it empty for

    Next time.

    DEL Backup\new /q


    ECHO off

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

BATCH files silent install or unassisted install? [ 3 Answers ]

Hello, :confused: I have many application's that I install at my place of employment. These applications have been packaged into a .exe, I currently install these apps VIA Batch files as there are many prerequisites required to install before installing the application itself i.e.. Oracle 9 etc....

Batch files, add/remove programs check possible? [ 1 Answers ]

Hello, :confused: I am wondering if it is possible to have a batch file check the applications that are installed by checking add/remove programs? Or Maybe there is an easier way to accomplish this check with a batch file? Thanks for all of your time.

Batch File In Dos [ 2 Answers ]

How do I make a batch file in dos that will open a program. I need to name the file S The file is acct\prog\solomon\solomon I have this in one PC but forgot how it create the command.

If I file 1040NR, do I file state as nonresident? [ 1 Answers ]

The title says it all-I worked in several states but I am foreigner. Does that mean that I file state taxes as non-resident as well?


View more questions Search