-
Batch Help
Hello.
For backups, I use DriveImage XML which runs from the Task Scheduler with this command: "C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
I have a 2nd hard drive that has 2 partitions, "D" and "J". After the program runs, I change the command to read J:\drive_c /s /l so it alternates week to week. Is there a way to make the batch file change the drive letter automatically after each run?
Thank you.
-
An easier alternative would be to have a batch file for each drive, and a batch file that Task Scheduler uses. Then, have the last command in each batch file copy the next batch file in the rotation to the batch file used in Task Scheduler.
-
jdc2000. Thanks for the reply.
I don't think I quite understand this. The only file to run would be the one that task scheduler uses so how would the other 2 run? If I put a line in the task scheduler batch file to copy one of the other batch files, how would it know to alternate? Or, am I reading this wrong?
Thank you.
-
Can't you just have 2 batch files and schedule them to run every 2 weeks?
Task1 - batchD (week 1, 3, 5, etc)
Task2 - batchJ (week 2, 4, 6, etc)
-
Example:
Backup1.bat file contents:
C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
copy Backup2.bat Backup.bat
Backup2.bat file contents:
C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"J:\drive_c /s /l
copy Backup1.bat Backup.bat
In Task Scheduler, use Backup.bat as the file to schedule, and start with Backup.bat as a copy of Backup1.bat
-
Here's one that will alternate between D: and J: all by itself, as well as record the beginning and completed date and time, (which could come in handy):
Code:
@echo off
if not exist "C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt" goto Backup2D
find "J:" "C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt">nul
if errorlevel 1 goto Backup2J
:Backup2D
echo dixml.exe backup to D:\drive_c beginning on %date% at %time%>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
"C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
echo dixml.exe backup to D:\drive_c completed on %date% at %time%>>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
goto End
:Backup2J
echo dixml.exe backup to J:\drive_c beginning on %date% at %time%>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
"C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
echo dixml.exe backup to J:\drive_c completed on %date% at %time%>>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
:End
After it has run, see the file "C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt" for the results.
-
Thank you all very much for the replies. Very informative. I've learned something today.
-