Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

Windows Batch script to create directories to backup to & housekeep directories older than 10 days


I can manually copy using an scp utility currently to another ssh server as follows :
c:\shareware\pscp -l administrator -pw mypasswd  *.pst 192.168.149.191:d:\bkarc\yyyymmdd\
  where yyyy is the year, mm is the 2 digit month & dd is the 2 digit day


I'll need a Windows batch ( .bat or .cmd ) script that will copy on daily basis my Outlook
archive files (.pst) to the ssh server.

The directory name will be different each day (yyyymmdd, eg on 3rd Feb 2010, yyyymmdd
would be 20100203)

I'll also need another script on the ssh server that runs daily to housekeep / delete away
d:\bkarc\yyyymmdd  that are older than 10 days
ASKER CERTIFIED SOLUTION
Avatar of Doug
Doug
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry I didn't use the code box but I couldn't submit it that way.  the page kept timing out.
Avatar of Bill Prew
Bill Prew

Can you tell me what the following command displays at a prompt on the system where this will run:

ECHO %DATE%

~bp
Avatar of sunhux

ASKER

Hi Skipper68, split into 2 scripts, pls


ECHO %DATE%    gives
Wed 08/18/2010


Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
==> ECHO %DATE%    gives
==> Wed 08/18/2010

Okay, my BAT scripts should work with that date format.

~bp
Avatar of sunhux

ASKER

Hi Skipper,  is your codes a VB script or a Windows batch script (.cmd or .bat)


Thanks Bill.


What about the other script to housekeep folders older than 10 days old.

Basically I'll run it as a scheduled .bat or .cmd  containing the line
rmdir/s/y d:\bkarc\Folders_older_than_10_days
Avatar of sunhux

ASKER


Sorry Bill, just noticed you've actually provided 2 scripts separated by the dashed line
-------------------
Avatar of sunhux

ASKER



Hi Bill,

One little thing I overlooked for the line below:
c:\shareware\pscp -l administrator -pw mypasswd  *.pst 192.168.149.191:d:\bkarc\%Today%\

The destination folder needs to be created in advance & I'm afraid it's not an option to ssh into
the destination server to create the directory.  So will need yr help to amend your 2nd script
(which is scheduled to run daily on the destination server) to create a folder for the next day.
So if today is 20100818, when the 2nd script runs at say 2am, it will create another folder for
next day ie "mkdir d:\bkarc\20100819".  Sorry for overlooking this earlier
Avatar of sunhux

ASKER


You've wonderfully calculated "Today" using
set Today=%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%

So in my last post above, I'll need to calculate
  set Tomorrow= ... ?? ...
& then insert into the 2nd script :
  mkdir d:\bkarc\%Tomorrow%

Also, would like to seek your advice if I prefix with "cmd/c" the following :
cmd/c c:\shareware\pscp -l administrator -pw mypasswd  *.pst 192.168.149.191:d:\bkarc\%Today%\

Reason is sometimes a certain *.pst file is locked, so I'll need the pscp to be able to continue to
copy/backup the other files over.

I thought of appending more pscp ie
cmd/c c:\shareware\pscp -l ... -pw ... *.ost ...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux

ASKER


> Would it be possible to place a small EXE file on the server

Yes, the above is possible.  Thanks & let me know how I can obtain it & how to use it
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux

ASKER


When running doff.exe, got a message that  "doff.exe is not a valid Win32 application" -
perhaps the copy I downloaded is for 64 bit?
Avatar of sunhux

ASKER


Strange, if doff.exe is run off my thumb drive, it gave that  "not a valid win32 app"
error but when it's run off the local hard disk, it's Ok
Yes, strange.  I did try a test here, I placed a copy of doff.exe on a usb drive here, and then ran the program from there, it worked fine.  Not sure why you had an issue, almost sounds like a bad copy to the usb or something.

~bp
Avatar of sunhux

ASKER


Anyway, thanks very much Bill, it worked on the local Hard disk, that's all I need