[<<]Message[>>]    [<<]Author[>>]    [<<]Subject        [<<]Thread    

Number : 4555 Date : 2003-05-08 Author : Garry Deane Subject : Re: A folder named %date% and a Differential Question Size(KB) : 3
--- In xxcopy@yahoogroups.com, Hans Klein wrote: > Hi All, > > I read with interest Jon's solution to delete the oldest > folder and would love a copy of his batch file. > > I am trying to get my head around the best approach to > a differential backup. The steps I see are > > 1. Make a full copy on say Friday night. > 2. If something has changed by Monday night, copy it to > the Monday directory. > 3. On Tuesday night files changed since Friday OR Monday > should be copied to Tuesday directory. > 4. On Wednesday night files changed since Friday OR Monday > OR Tuesday should be copied to Wed directory. > > etc > > Then on Friday ... full copy > Cycle for 4 weeks and start again. (hence my interest > in Jon's approach) > > I would then have a kind of version control taking the > minimum space. This should protect my users against > their own mad moments. > > Fine in theory but by now I'm getting a headache .. Help! > > Best Wishes to All > Hans This is quite do-able. What you need to do is use Xxcopy based on the archive bit. If the archive bit is set, it indicates that the file has been modified. The commands to do a full or incremental backup will be virtually identical except for the clearing of the archive bit after a full backup. Thereafter, if the archive bit has been set, the file needs to be backed up. So for a full backup you would do: Xxcopy /bu/ac //ac=ignore archive bit and clear after copy For an incremental backup you would do: Xxcopy /bu/a //a=copy if archive bit is set and leave set Since you're working on a weekly cycle, this lends itself to using the new ISO week macro introduced in version 2.84.3 - see my recent post in http://groups.yahoo.com/group/xxcopy/message/4515. To account for your first day of the backup week being Friday (ISO day 5) you need to offset the date calculation by adding 3 days using /TM+3 so that Friday is treated as Monday and becomes day 1, Sat day 2, ... Thu day 7. So you would define your destination directory using: Xxcopy d:\backup\/$ii-iwk$\/$k$\ /tm+3 This would give the following directory structure: Fri 2003/05/02 - d:\backup\03-W19\1\ <= Full backup Mon 2003/05/05 - d:\backup\03-W19\4\ <= Incremental backup : : Thu 2003/05/08 - d:\backup\03-W19\7\ <= Incremental backup Fri 2003/05/09 - d:\backup\03-W20\1\ <= Full backup To maintain 4 weeks of data, you need to delete the backup which was created 5 weeks ago. To do that, use the /RMDIR option each Friday with a date macro offset by -32 days (5*7-3) and delete all the data corresponding to that week. Xxcopy d:\backup\/$ii-iwk$\ /rmdir/rsy/tm-32 The only thing left is to determine whether today is Friday. I'll assume you're on NT/W2k/XP but if your using W9x/ME you can do this using CURRENT.BAT as recently posted in http://groups.yahoo.com/group/xxcopy/message/4543. Here's a quick and dirty (untested) outline of the batch file to achieve what you want. You'll need to add some error checking, create log files and thoroughly *TEST* before use. @echo off :: Get the day abbreviation for today (NT/W2k/XP) for /f %%a in ('date/t') do set DayofWeek=%%a :: Set the archive bit parameter for full (/ac) or incremental (/a) set a-bit=a if "%DayofWeek%"=="Fri" set a-bit=ac :: Carry out the backup to a modified ISO week directory Xxcopy c:\data\ d:\backup\/$ii-iwk$\/$k$\ /tm+3/bu/%a-bit% :: If today is Friday, delete the week of backup data for 5 weeks ago if "%DayofWeek%"=="Fri" Xxcopy d:\backup\/$ii-iwk$\ /cb/rmdir/rsy/tm- 32 And that's all there is to it - 6 lines ignoring comments. PS I've just seen Kan's reply and although I don't think it does quite what you are after, it includes some good ideas regarding month and day macros which you might want to use instead of the ISO week. Garry
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.