Batch file to backup the documents folder on a continuing basis deleting old files while replacing with udated ones

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Windward111
Posts: 2
Joined: 09 Feb 2019 14:04

Batch file to backup the documents folder on a continuing basis deleting old files while replacing with udated ones

#1 Post by Windward111 » 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.

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
Any help you can offer would be GREATLY appreciated.

Thanks and have a great day!
Jim Day :roll:
Honolulu, HI

Ed Dyreen
Expert
Posts: 1566
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch file to backup the documents folder on a continuing basis deleting old files while replacing with udated ones

#2 Post by Ed Dyreen » 14 Feb 2019 18:02

Hello,

I want to bring to your attention that I use a freeware program called richCopy 4.0 that can do exactly what you want. Copy/move/purge... The cool thing is it has a GUI but also can be scripted using batch. You simply start the program read the help configure it and save the displayed line in the options screen to a batch script or just click run.

The program can be scheduled and you can control the conditions under which files are updated ( last write / date ? etc.. ). If files deleted in source should be deleted in backup( purge mode ), select fail conditions, retries... Secures FAT/NTFS( does not verify writes and is insecure by design ) writes by reintroducing the old copy /V behavior( not required for ext2 ext3 filesystems which are secure by design ). Uses multiple threads so all those nasty small files are copied much more rapidly than if you used windows explorer.

Windward111
Posts: 2
Joined: 09 Feb 2019 14:04

Re: Batch file to backup the documents folder on a continuing basis deleting old files while replacing with udated ones

#3 Post by Windward111 » 15 Feb 2019 02:00

Thanks so much for your suggestion. Actually, I used RichCopy on my Windows 7 OS successfully, but I couldn’t get the options to save on my Windows 10 system. I know the settings, but after I enter them, they won’t save! :evil: :cry:

I will try again.
Thanks again, I really liked using RC in the past.
Jim 8)

Ed Dyreen
Expert
Posts: 1566
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch file to backup the documents folder on a continuing basis deleting old files while replacing with udated ones

#4 Post by Ed Dyreen » 21 Feb 2019 18:22

The defaults are saved to a file 'defaults.cfg'. You could edit the file using notepad.

Or just copy the command line switches to a batch and run from there so the config file is not used.

Post Reply