Need a backup batch file

Posted on 2005-04-08
Last Modified: 2010-08-05
I have USB flash drive.

I get to work in the morning and copy all the data from the USB to the Work PC.  At the end of the day, I copy the entire folder from the Work PC back to the USB.

I take the USB home and make updates, change files, write to the USB directly.  Bring it back tomorrow and repeat the whole process.

Problem is my USB is getting full and it takes along time to copy back and forth all the files between the USB and Work PC.  I only want to copy the files that have changed each time.

Assuming on the Work PC the files are at C:\Folder and the USB is F: please provide a script and/or batch file that will solve my problem without causing data loss.
Question by:pcarlow
    LVL 16

    Expert Comment

    I think you can use the XCOPY command to accomplish this.  Just put the text below into a batch file like USBCopy.bat to copy from your C:\Folder tot eh USB drive.  It will copy only newer files than what is on the destination.

    XCOPY C:\FOLDER\*.* F:\ /D /E /Q /Y

    LVL 1

    Author Comment

    I'll actually need 2 scripts, one to copy the changes from the night before off the USB and then another to copy the changes from that day back to the USB.  And I need it to work for sure, because this is very important data to me.
    LVL 16

    Expert Comment


    The other direction would be:

    XCOPY F:\ C:\FOLDER\*.* /D /E /Q /Y

    Test it first.  Put a current copy of all your files in a temporary folder and test it in both directions.  If something screws up you still have your backup in a temproary folder.

    LVL 16

    Accepted Solution

    You only need the lines described above in a single batch file. The /d variable will only copy over files that have the newest time stamp. The batch file would accidentally overwrite the new data. If your path's have spaces in them, be sure to use quotations like below. Finally, a single asterick * only needs to be entered after the source path.
    xcopy "source\*" "destination" /your variables.
    xcopy "f:\folder\*" "c:\folder\" /d /e /q /y
    xcopy "c:\folder\*" "f:\folder\" /d /e /q /y

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
    This video discusses moving either the default database or any database to a new volume.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now