[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Need a backup batch file

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.
0
pcarlow
Asked:
pcarlow
  • 2
1 Solution
 
robrandonCommented:
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



0
 
pcarlowAuthor Commented:
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.
0
 
robrandonCommented:

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.

0
 
craylordCommented:
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
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now