xcopy "Source" "Destination" /c /q /d /e /h /yFor the Source and Destination you just have to put in the folder or file path that you want to backup and the location to backup to. If you have spaces in the path then you will need to include the quotation marks, for example, “C:\Mozilla Firefox\” would need to have the quotes because of the space. So an example command with the path in it would look like this:
xcopy "C:\Mozilla Firefox\" "\\Server\C\Firefox\" /c /q /d /e /h /yNow you are probably wondering what the “/c /q /d /e /h /y” does at the end of that command. Each one of those parameters perform a different action. Microsoft has a long list of available parameters that can be added but those are the ones that I use. Here is what each of them does:
- /c – Ignores all errors which helps make sure that the backup will complete even if there is a small problem.
- /q – Prevents the command prompt from displaying an “xcopy” message for every file or folder that is copied.
- /d – Only synchronize Source files if they are newer than the files in the destination. Otherwise every file will get copied each time the batch file is executed.
- /e – Copy all subdirectories even if they are empty.
- /h – Copy hidden and system files.
- /y – Prevents an “Overwrite existing file?” prompt for each file that already exists in the destination.
Feel free to remove any of those parameters that you don’t feel are necessary but those are the ones that I have found to work best for me. Inside the batch file you can add more than one “xcopy” command by separating them by a new line. That means you can backup multiple folders with one single batch file. Once you have the batch file completed and saved you can right-click on it and select “Run” to see if everything works how you want it to. You should probably test it on a small folder with just some test files before you go and do the real thing to prevent any unexpected actions. If everything works great then maybe you want to think about scheduling it to run itself using the Scheduled Tasks located in the Control Panel. Now that wasn’t so bad was it?