Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Batch file experts

  • 06-10-2004 9:16am
    #1
    Registered Users, Registered Users 2 Posts: 11,264 ✭✭✭✭


    Hi

    I currently have a simple batch file for backing up data to an external hard drive. It uses xcopy and overwrites whatever files have been changed. Some times I need to restore this data to another machine. However files that no longer exist on the original machine are still in the backup and get restored to the 2nd machine, this is a problem for me. I don't want to have to overwrite every file when backing as there is over 4GBs of data and this takes too long.

    So how can I moidfy the batch file to remove files on the external hard disk that no longer exist on the original PC?

    Was thinking of looking on the external drive first,
    Is it possible to loop through all files and do something like
    IF NOT EXIST ??? del /f ???

    How would I get the file names?

    Everything is on a windows env and I would be only using the available DOS commands, no 3rd party apps.

    Thanks


Comments

  • Closed Accounts Posts: 625 ✭✭✭ThreadKiller


    I don't think you'll be able to do that to be honest, even using explicit backup software it's still going to be restoring everything you backed up.

    Be interested in seeing your batch file though


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    You could look at the FOR command.


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    There was a program I used before.. I think it was called SecondCopy97 or something similiar. It was a pretty basic program but it let you do what you're looking to do.

    Not got a link to hand, google might throw up something for you.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,599 Mod ✭✭✭✭Capt'n Midnight


    Please specify exact OS !

    Xcopy syntax and options vary a hell of lot.
    eg:
    in DOS / or win 9x in DOS mode you can't use /D
    in 9X command prompt you can use /D
    in NT you can't use Exclude where as in 2000 you can
    in XP you have to use pipe the letter "A" (for all) to get it to overwrite files in batch mode - which you don't have to do in 2000

    the FOR command is only native to NT/2K/XP

    If you are doing a one off copy you could try this.
    attrib *.* -a /s
    remove backup attrib
    xcopy *.* x:\*.* /s /m
    copies only files not copied already and marks them as copied
    Note there are other options for hidden / readonly / system files and even then you can't copy files in use

    If you have XP home - look for NTBACKUP.MSI on the CD and run it
    ya might as well take a snapshot of the system state.

    NT - backup only to tape.
    Dos/Win9x backup only with compression turned off and even then painfull
    2K/XP - I think NTbackup is compat between these.


  • Registered Users, Registered Users 2 Posts: 11,264 ✭✭✭✭jester77


    Thanks Capt'n Midnight,

    OS is win2k

    My file is currently something like this:
    xcopy c:\xyz\*.* i:\XYZ\xyz /c /s /r /d /y /i > i:\XYZ\resync.log

    That works ok for backing up files that were modified. But if a file was deleted on the machine it still remains in the backup. This is a problem for me when I restore as some of the "already deleted" files contain source code and this cause compilation errors.

    I tried the following but didn't work,

    FOR %%v IN (i:\XYZ\*.*) DO IF NOT EXIST c:\%%v del /f i:\XYZ\%%v

    %%v is only the filename and not the path plus it doesn't recurse through the folders...


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 335 ✭✭Alanm


    Have a look at Robocopy - i think it's comes with the 2k resource kit (I can mail you a copy of it if you like - it's just an exe). It has a mirror option which will do exactly what need!

    hth


  • Registered Users, Registered Users 2 Posts: 11,264 ✭✭✭✭jester77


    Thanks Alanm,
    That would be great, I'll PM you my email.


  • Moderators, Arts Moderators Posts: 35,741 Mod ✭✭✭✭pickarooney


    If you install a bash shell (like cygwin) it's a piece of piss to write a script for these kind of things. It might be hammers to kill mosquitoes for this job, but if you regularly do various file-copying jobs, it's well worth a look into.

    If not, maybe check the IF command syntax on this page, usign dir/s to check the files on the external drive.


  • Registered Users, Registered Users 2 Posts: 2,755 ✭✭✭niallb


    I'd agree with Captain Midnight on the incompatible xcopy#s.
    Unexpected grief is a bad thing in backup software.
    Using attrib creatively and sticking to simpler xcopy options might work.

    If you do end up looking at other tools, take a look at rsync.
    It's designed for remote synchronisation, but works very well
    between two locations on the same machine.
    http://heanet.dl.sourceforge.net/sourceforge/sereds/cwRsync_1.2.6_Installer.zip
    looks like it has all required dlls included (and a copy of openssh in case you
    want to go remote with it.)

    NiallB


  • Registered Users, Registered Users 2 Posts: 483 ✭✭banbutcher


    a little bit off topic im lookin for a batch file that will install all the esential apps on a cd like an auto play option! all i want is to put the cd in and then it will run the installers completly without me havin to touch it!! any ideas?


  • Advertisement
  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,599 Mod ✭✭✭✭Capt'n Midnight


    banbutcher wrote:
    a little bit off topic im lookin for a batch file that will install all the esential apps on a cd like an auto play option! all i want is to put the cd in and then it will run the installers completly without me havin to touch it!! any ideas?
    they are called viruses..

    a cautionery tale: Screw up System ? [Y/N]
    once upon a time I made a bootable CD to do something similar, unfortunatley the disk I used was a BIOS upgrade floppy for a laptop. CD booted up OK and without asking flashed the BIOS on the old desktop. Result - dead motherboard.

    check the options on the app for silent installs - they are ALL different
    sysdiff might be usefull - but in the Windows world you can't copy applications they must be installed...


Advertisement