Batch file to backup the documents folder on a continuing basis deleting old files while replacing with udated ones
Posted: 14 Feb 2019 14:26
Aloha,
I am trying to write a batch backup program using DOS to:
a) Make a backup copy of my 'Documents' file, and
b) On subsequent runs update only those files that have been changed since the last backup by copying over them. I.e., I don't really have the need to save old copies of the backed up files.
I have Windows 10.
The directory where the documents folder resides is C:\users\James Day> The folder is 'Documents'.
The USB flash drive I would like to use for my backup is H:\.
Here is a truncated version of the batch file I made for my girl friend's computer, but no matter how I massage this file, I can't get it to work on my computer. She has Windows 7, which might be the reason it won't work on mine which is Windows 10.
Any help you can offer would be GREATLY appreciated.
Thanks and have a great day!
Jim Day
Honolulu, HI
I am trying to write a batch backup program using DOS to:
a) Make a backup copy of my 'Documents' file, and
b) On subsequent runs update only those files that have been changed since the last backup by copying over them. I.e., I don't really have the need to save old copies of the backed up files.
I have Windows 10.
The directory where the documents folder resides is C:\users\James Day> The folder is 'Documents'.
The USB flash drive I would like to use for my backup is H:\.
Here is a truncated version of the batch file I made for my girl friend's computer, but no matter how I massage this file, I can't get it to work on my computer. She has Windows 7, which might be the reason it won't work on mine which is Windows 10.
Code: Select all
@echo off
:: variables
set drive=j:\Phyllis
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo ### Backing up My Documents...
...%backupcmd%"C:\Documents and Settings\All Users\Desktop" "%drive%\"
%backupcmd% "C:\Users\Phyllis\Documents\2010 - Switzerland" "%drive%\Phyllis\2010 - Switzerland"
%backupcmd% "C:\Users\Phyllis\Documents\2013 - Austria" "%drive%\Phyllis\2013 - Austria"
%backupcmd% "C:\Users\Phyllis\Documents\Worm Project copy" "%drive%\Phyllis\Worm Project copy"
echo Backup Complete!
@pause
Thanks and have a great day!
Jim Day
Honolulu, HI