|
|
Krister's Blog
krister at hallergard dot com
| Last Updated:
2014-02-01
|
Xcopy - Incremental Backup
I write simple batch-files to make incremental backup of new and changed files. Here follows the batch-file for backup of personal data files
such as Office documents and MultiMedia files. I do this a couple of times per week and it ususally takes about a minute:
View Video 3 min
| |
|
echo a|xcopy c:\Krister\*.* d:\Krister\*.* /d /h /r /s /c
echo a|xcopy c:\Dropbox\*.* d:\Dropbox\*.* /d /h /r /s /c
echo a|xcopy c:\Users\Krister\Music\*.* d:\Users\Krister\Music\*.* /d /h /r /s /c
echo a|xcopy c:\Users\Krister\Pictures\*.* d:\Users\Krister\Pictures\*.* /d /h /r /s /c
echo a|xcopy c:\Users\Krister\Videos\*.* d:\Users\Krister\Videos\*.* /d /h /r /s /c
|
Here follows the batch-file for backup of program files and system files. System files like the registry cannot be copied in this way when they are running
- thus the need for partitioning: Boot one partition (C:\Windows XP - Disk2 Partition2) to backup another partition (D:\Windows 7 - Disk2 Partitions1) to a third
partition (F:\ - Disk1 Partition4). I do this about every other week to complement the restore points of the operating system. It takes about half an hour:
|
|
echo a|xcopy "d:\Program files\*.*" "f:\Program files\*.*" /d /h /r /s /c
echo a|xcopy "d:\Program files (x86)\*.*" "f:\Program files (x86)\*.*" /d /h /r /s /c
echo a|xcopy d:\bat\*.* f:\bat\*.* /d /h /r /s /c
echo a|xcopy d:\Users\*.* f:\Users\*.* /d /h /r /s /c
echo a|xcopy d:\Windows\*.* f:\Windows\*.* /d /h /r /s /c
echo a|xcopy d:\PerfLogs\*.* f:\PerfLogs\*.* /d /h /r /s /c
echo a|xcopy "d:\ProgramData\*.*" "f:\ProgramData\*.*" /d /h /r /s /c
|
On the command line you can run "xcopy /?" to find out about all 25 or so options. I use these command switches:
- /d:m-d-y Copies files changed on or after the specified date
- /d When no date is given, copies only those files whose source time is newer that the destination time
- /m Copies only files with the archive attribute set, turns off the archive attribute
- /h Copies hidden and system files also
- /r Overwrites read-only files
- /s Copies directories and subdirectories except empty ones
- /c Continues copying even if errors occur
|