Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Save 5 backup copies

13 views
Skip to first unread message

gene martinez

unread,
May 19, 2008, 1:16:09 PM5/19/08
to
I have a batch file that is run at night that copies my mail folder,
my servers alive folder and a few other program folders. What I'd like
the batch file to do is save my 5 days of folders. How can I do this
with a bacth file. The folders don't need to be dated, just folder1,
folder2 etc....

Thanks

Luuk

unread,
May 19, 2008, 1:40:23 PM5/19/08
to
gene martinez schreef:

@echo off
rem REMOVE the 5th backup
rd /S /Q 5
rem MOVE 4th backup to 5th
mv 4 5
rem MOVE 3rd backup to 4th
mv 3 4
rem MOVE 2nd backup to 3rd
mv 2 3
rem MOVE 1st backup to 2nd
mv 1 2
rem COPY new backup to 1st
xcopy /I *.* 1

--
Luuk

gene martinez

unread,
May 19, 2008, 7:59:56 PM5/19/08
to
Luuk <Lu...@invalid.lan> wrote:

Thanks now why didn't I think of that.. :)

Again THANKS

foxidrive

unread,
May 19, 2008, 9:14:36 PM5/19/08
to

Where did you find the mv utility? ;-)


** Posted from http://www.teranews.com **

Esra Sdrawkcab

unread,
May 20, 2008, 1:18:57 AM5/20/08
to

Unix port, by the sound of the name. Though the "rd" synttax is fine in XP.

billious

unread,
May 20, 2008, 2:00:48 AM5/20/08
to

"gene martinez" <nj...@eclipse.net> wrote in message
news:48321438...@news.netcarrier.net...

Personally, I believe that this would be easier - but it might depend on
your OS, and assumes that directories 1,2,3,4,5 exist

This solution developed using XP
It may work for NT4/2K

----- batch begins -------
[1]@echo off
[2]rd /s /q 5
[3]ren 4 5
[4]ren 3 4
[5]ren 2 3
[6]ren 1 2
------ batch ends --------

Lines start [number] - any lines not starting [number] have been wrapped and
should be rejoined. The [number] that starts the line should be removed

Naturally, your backup should then be made to 1

Timo Salmi

unread,
May 20, 2008, 10:34:15 AM5/20/08
to

83} How to archive files with a rotation of five latest generations?
http://www.netikka.net/tsneti/info/tscmd083.htm

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

sKurt

unread,
May 20, 2008, 12:33:54 PM5/20/08
to
gene martinez wrote:

Here is a snip that I use for a Cascading Rename to keep 7 days.

sKurt


*snip

::+=(242)=================================+
::| CASREN (CASCADING RENAME) BACKUP FILE |
::+=======================================+

CD\%b%%a%-BU>NUL

::+=(243)====================================+
::| First, does the CA1231BU.ZIP file exist? |
::| If it doesn't exsist, go create it now |
::+==========================================+

[01] IF NOT EXIST %b%%a%%d%BU.ZIP GOTO :_DO_ZIP_LOCAL >NUL
[02] IF "%D1%"=="/DEBUG" XSET /COLOR YELLOW /PROMPT "CA1231BU.ZIP
CASREN FILE PROCESSING (243)"

::+=(244)==================+
::| If the directories are |
::| NOT there, create them |
::+========================+

IF NOT EXIST OLD01\NUL MD OLD01 >NUL
IF NOT EXIST OLD02\NUL MD OLD02 >NUL
IF NOT EXIST OLD03\NUL MD OLD03 >NUL
IF NOT EXIST OLD04\NUL MD OLD04 >NUL
IF NOT EXIST OLD05\NUL MD OLD05 >NUL
IF NOT EXIST OLD06\NUL MD OLD06 >NUL
IF NOT EXIST OLD07\NUL MD OLD07 >NUL

::+============================================================+::

IF NOT EXIST OLD06\%b%%a%%d%BU.ZIP GOTO OLD05
IF EXIST OLD07\%b%%a%%d%BU.ZIP ATTRIB -R OLD07\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD07\%b%%a%%d%BU.ZIP DEL OLD07\%b%%a%%d%BU.ZIP >NUL

MOVE OLD06\%b%%a%%d%BU.ZIP OLD07 >NUL

::+============================================================+::

IF NOT EXIST OLD05\%b%%a%%d%BU.ZIP GOTO OLD04
IF EXIST OLD06\%b%%a%%d%BU.ZIP ATTRIB -R OLD06\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD06\%b%%a%%d%BU.ZIP DEL OLD06\%b%%a%%d%BU.ZIP >NUL

MOVE OLD05\%b%%a%%d%BU.ZIP OLD06 >NUL

::+============================================================+::

IF NOT EXIST OLD04\%b%%a%%d%BU.ZIP GOTO OLD03
IF EXIST OLD05\%b%%a%%d%BU.ZIP ATTRIB -R OLD05\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD05\%b%%a%%d%BU.ZIP DEL OLD05\%b%%a%%d%BU.ZIP >NUL

MOVE OLD04\%b%%a%%d%BU.ZIP OLD05 >NUL

::+============================================================+::

IF NOT EXIST OLD03\%b%%a%%d%BU.ZIP GOTO OLD02
IF EXIST OLD04\%b%%a%%d%BU.ZIP ATTRIB -R OLD04\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD04\%b%%a%%d%BU.ZIP DEL OLD04\%b%%a%%d%BU.ZIP >NUL

MOVE OLD03\%b%%a%%d%BU.ZIP OLD04 >NUL

::+============================================================+::

IF NOT EXIST OLD02\%b%%a%%d%BU.ZIP GOTO OLD01
IF EXIST OLD03\%b%%a%%d%BU.ZIP ATTRIB -R OLD03\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD03\%b%%a%%d%BU.ZIP DEL OLD03\%b%%a%%d%BU.ZIP >NUL

MOVE OLD02\%b%%a%%d%BU.ZIP OLD03 >NUL

::+============================================================+::

IF NOT EXIST OLD01\%b%%a%%d%BU.ZIP GOTO CURR
IF EXIST OLD02\%b%%a%%d%BU.ZIP ATTRIB -R OLD02\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD02\%b%%a%%d%BU.ZIP DEL OLD02\%b%%a%%d%BU.ZIP >NUL

MOVE OLD01\%b%%a%%d%BU.ZIP OLD02 >NUL

::+============================================================+::

IF EXIST OLD01\%b%%a%%d%BU.ZIP ATTRIB -R OLD01\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD01\%b%%a%%d%BU.ZIP DEL OLD01\%b%%a%%d%BU.ZIP >NUL
IF EXIST %b%%a%%d%BU.ZIP MOVE %b%%a%%d%BU.ZIP OLD01 >NUL

::+============================================================+::

::+=(244)===========================+
::| IF BU.ZIP doesn't exist, create |
::+=================================+

:_DO_ZIP_LOCAL

[01] IF "%D1%"=="/DEBUG" XSET /COLOR WHITE /PROMPT "NETBACK - IF BU.ZIP
DOESN'T EXIST, CREATE (244)"

*snip

--

Luuk

unread,
May 20, 2008, 3:21:06 PM5/20/08
to
foxidrive schreef:

oeps, indeed gnu, but MOVE should word also... ;-)

D:\TEMP\temp>mv --version
mv (GNU coreutils) 6.10
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Parker, David MacKenzie, and Jim Meyering.


--
Luuk

0 new messages