You could do it like this:
01. @echo off
02. set versions=3
03. set Source=c:\BackupFolder
04. set Target=\\Pegasus\DriveE\Backups
05.
06. for /L %%a in (1,1,%versions%) do if not exist "%Target%\Backup%%a" md
"%Target%\Backup%%a"
07. for /F %%a in ('dir /ad /b /o-d "%Target%"') do set Folder=%%a
08. rd /s /q "%Target%\Backup%%Folder%"
09.
10. robocopy /s "%Source%" "%Target%\Backup%%Folder%" *.*
11. c:\Tools\blat.exe /.. /..
In Line02 you set the number of versions you require. You
could maintain 10 versions if you wanted.
In Line03 you set your source folder.
In Line04 you set your target folder. I note that you called
the target folder "source" in your own example. While you
are free to call your folders anything you like, I do not think
it's a good idea to call a "target" folder "source. It tends to
confuse people.
Line06 will generate the required number of target folders
(unless they already exist).
Line07 will pick the oldest of your target folders.
Line08 will remove the oldest target folder.
Line10 will perform the backup process.
Line11 will generate the automatic mail. using blat.exe
(which you can download from a number of sites).
You now need to do a little bit of your own work:
- Study the robocopy documentation to see how to
capture a log file of the process.
- Study the blat documentation to see how to send
this log file to yourself.
In each case it's standard stuff: Type robocopy /?
at the Command Prompt to see the help file for the
command.
Enjoy!
"Eric" <(E-Mail Removed)> wrote in message
news:3C22D2E5-7592-4C65-842D-(E-Mail Removed)...
> Thank you very much for suggestions
> I would like to keep the last 3 backup copy only.
> On my PC, there are 3 folders for backup storage, which will be shown as
> below.
> C:\Backup1, which will alway be the latest version of backup
> C:\Backup2
> C:\Backup3, which will alway be the oldest version of backup
>
> When I perform the backup, batch file will delete the folder C:\Backup3,
> and
> rename C:\Backup2 into C:\Backup3, and rename C:\Backup1 into C:\Backup2,
> and
> create a folder C:\Backup1, then at this moment, batch file would copy
> everything from source folders into C:\Backup1 folder.
> Therefore, I can keep the backup records for a period of time.
> Once the backup process is done, then like what you said,
> 1) log the output generated by it
> 2) generate an automatic EMail message to yourself.
>
> Could you please tell me how to write the code to perform this tasks?
>
> @echo off
> robocopy /s "c:\BackupFolder"
> \\192.168.3.5\SourceFolder *.*
>
> Thank you very much for any suggestions
> Eric
>
>
>
>
> "Pegasus (MVP)" wrote:
>
>> Here you go:
>>
>> @echo off
>> robocopy /s "c:\documents and settings\Eric"
>> \\SomePC\SomeShare\SomeFolder
>> *.*
>>
>> This is the most basic command. You can have several
>> of these, you can log the output generated by it and you
>> can even generate an automatic EMail message to yourself.
>> Remember that every automatic process must be checked
>> regularly!
>>
>> Use the Task Scheduler (via the Control panel) to launch
>> this task automatically. It's best to use a dedicated account
>> with administrative privileges and a good password to run
>> the task.
>>
>>
>> "Eric" <(E-Mail Removed)> wrote in message
>> news:29C0612B-F347-478A-AB81-(E-Mail Removed)...
>> > Thank you very much for your suggestions
>> > Could you please provide any sample on batch files using xcopy.exe or
>> > robocopy.exe to perform this task based on schedule?
>> > I look forward to your reply
>> > Thank you very much for any suggestions
>> > Eric
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >>
>> >> "Eric" <(E-Mail Removed)> wrote in message
>> >> news:199FF5E5-546D-4D43-99A0-(E-Mail Removed)...
>> >> > Does anyone have any suggestions on any basic Backup tools for XP?
>> >> > I have 10 PCs, one of them is used to share files for 8 PCs and
>> >> > another
>> >> > one
>> >> > intended to backup the sharing folders from previous one. Does
>> >> > anyone
>> >> > have
>> >> > any suggestions on any basic backup tools for XP to perform
>> >> > scheduled
>> >> > backup
>> >> > procedures? What I intend to do is to make a copy of sharing folders
>> >> > and
>> >> > overwrite the previous backup copy, and I would like to do it every
>> >> > Sunday
>> >> > at
>> >> > 6pm.
>> >> > Does anyone have any suggestions?
>> >> > Thanks in advance for any suggestions
>> >> > Eric
>> >>
>> >> A batch file using xcopy.exe or robocopy.exe could do this
>> >> very nicely when invoked by the Task Scheduler.
>> >>
>> >>
>> >>
>>
>>
>>
|