Creating a .bat backup program not working

alyoob

Member
I am trying to execute a backup program using notepad then saving the file as a .bat so the at it will execute / run the backup program to save my content to another hard drive. I tried the original code and it worked fine it transferred the content in c:\testsource to c:\testbackup when i try to change the destination folder to another folder and tried the program again it did not transfer the content in c:\testbackup to the other folder. Can somebody show me what i am doing wrong.

@echo off
xcopy c:\testsource c:\testbackup /m /e /y
 
I am trying to execute a backup program using notepad then saving the file as a .bat so the at it will execute / run the backup program to save my content to another hard drive. I tried the original code and it worked fine it transferred the content in c:\testsource to c:\testbackup when i try to change the destination folder to another folder and tried the program again it did not transfer the content in c:\testbackup to the other folder. Can somebody show me what i am doing wrong.

@echo off
xcopy c:\testsource c:\testbackup /m /e /y

xcopy c:\testsource *.* c:\testbackup

the above will copy from testsource directory to c:\testbackup
if you have sub directorys you need to add the /s switch (for subdirectorys).

___________________
for thought: after ya do initial backup or what ever from dos
command replace is the one of interest for incremental backup.
 
Last edited:
I don't see why it wouldn't work, especially since it worked previously with the original destination folder. I noticed you're using /m switch, (copies only files with the archive attribute set), so creation of a destination folder is dependent on source containing file with archive attribute - may or may not be relevant. Here's a bat file I use for the same purpose.

@echo off
echo.
echo Backup Files
echo.
pause
dir C:\windows\system32
rmdir D:\Backup /s/q
md "D:\Backup\Computer Files"
xcopy "D:\Computer Files" "D:\Backup\Computer Files" /e/f/h/k/y
md D:\backup\Contacts
xcopy C:\Users\Name\Contacts D:\Backup\Contacts /e/f/h/k/y
md D:\Backup\Favorites
xcopy C:\Users\Name\Favorites "D:\Backup\Favorites" /e/f/h/k/y
md D:\Backup\Documents
xcopy "D:\My Documents" D:\Backup\Documents /e/f/h/k/y
md D:\Backup\Pictures
xcopy D:\Pictures D:\Backup\Pictures /e/f/h/k/y
echo.
echo Backup Complete
echo.
pause

I use rmdir to delete the old file at start, otherwise deleted files remain, and also use the /h & /k switches.
 
Back
Top