I recently picked up a NAS system (Synology DS1515+) to migrate a lot of my core files, pictures, business files, music, etc. to. During the transition I had times where I was syncing over files and then had to do some work and updated files locally. I want to make sure to get things moved over and make sure I get EVERYTHING!
This is what I did for a real simple sync of my files from my Windows systems to the NAS. This isn’t a true “syncing” of files, it’s more of a my local system is the “system of record” and I want to move any updated or new files to the NAS. This wont pickup deleted files or file moves or anything like that, so this is simply just a way to get the files over and then if you happen to update one or add a couple it will copy them over as well.
What I did was to simply create a bat file that uses xcopy to move the files.
Here is the basic sync.bat file I created to copy over a couple of my folders.
@echo off xcopy C:\Business \\S2-NAS-01\Business /E /C /H /R /D /Y xcopy C:\Pictures \\S2-NAS-01\Pictures /E /C /H /R /D /Y
As you can see, and I mentioned above this simply uses the xcopy command to move and updates files and I’m using the /E /C /H /R /D and /Y options.
On first run, this goes and copies over all of the files and directories it can find…
9815 File(s) copied
Then on subsequent runs it will only copy over new or changed files from the local system.
0 File(s) copied
So what do the options I’m using do? There is a full list of options down below, but the ones that worked the best for me are:
- /E – Copies directories and subdirectories, including empty ones.
- /C – Continues copying even if errors occur.
- /H – Copies hidden and system files also.
- /R – Overwrites read-only files.
- /D – Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
- /Y – Suppresses prompting to confirm you want to overwrite an existing destination file.
The really important option here is the /D, without it, everything would be copied every time, and that’s not exactly what I was going for.
This worked out pretty well for me… Do you have some other method or program that you like to use to sync files? Let us know in the comments!
> xcopy /?
Copies files and directory trees. XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B] [/J] [/EXCLUDE:file1[+file2][+file3]...] source Specifies the file(s) to copy. destination Specifies the location and/or name of new files. /A Copies only files with the archive attribute set, doesn't change the attribute. /M Copies only files with the archive attribute set, turns off the archive attribute. /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. /EXCLUDE:file1[+file2][+file3]... Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively. /P Prompts you before creating each destination file. /S Copies directories and subdirectories except empty ones. /E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T. /V Verifies the size of each new file. /W Prompts you to press a key before copying. /C Continues copying even if errors occur. /I If destination does not exist and copying more than one file, assumes that destination must be a directory. /Q Does not display file names while copying. /F Displays full source and destination file names while copying. /L Displays files that would be copied. /G Allows the copying of encrypted files to destination that does not support encryption. /H Copies hidden and system files also. /R Overwrites read-only files. /T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories. /U Copies only files that already exist in destination. /K Copies attributes. Normal Xcopy will reset read-only attributes. /N Copies using the generated short names. /O Copies file ownership and ACL information. /X Copies file audit settings (implies /O). /Y Suppresses prompting to confirm you want to overwrite an existing destination file. /-Y Causes prompting to confirm you want to overwrite an existing destination file. /Z Copies networked files in restartable mode. /B Copies the Symbolic Link itself versus the target of the link. /J Copies using unbuffered I/O. Recommended for very large files. The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line.