- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: Monthly Backups....dos style =)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2004 03:37 AM
07-12-2004 03:37 AM
cd\
cd c:\Program Files\Winzip
for /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (
set year=%%k
set month=%%i
set day=%%j
)
wzzip c:\backup\Daily\h%month%%day%%year%.zip -r -p -t h:\*.*
I'm hoping to make monthly's now. Basically all files that were made in June '04. Is this possible?
Thanks for your help ahead of time! =)
Monty.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2004 05:34 AM
07-12-2004 05:34 AM
SolutionI am assuming that u r looking for the batch file to backup all files which were created in June04 into one zip file with the name as todays date eg. h07122004.zip
Is this right??
if yes then u have to check filter the files in h:\ right now u have given it as h:\*.* which means all files..
is there a file name format used to find the files which are created for this month??
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2004 05:52 AM
07-12-2004 05:52 AM
Re: Monthly Backups....dos style =)
It sounds like it might be an awfully big Dos task to filter, and if so then I can just do it manually.
Thanks again for your time! =)
Monty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2004 06:00 AM
07-12-2004 06:00 AM
Re: Monthly Backups....dos style =)
this can be achieved using the windows scripting.. wait for the next post.. i will get it ..
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2004 10:41 AM
07-12-2004 10:41 AM
Re: Monthly Backups....dos style =)
If you run the monthly one each month, at the start of the month, it will be easy to create the batch file (See example 1).
If you are going to run the monthly from within your daily backup script, it will take more work (See example 2).
Example 1 (run after end of month)
--------------
cd\
cd c:\Program Files\Winzip
for /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (
set year=%%k
set /a month=%%i-1
if %month% < 10 set month=0%month%
set day=%%j
)
wzzip c:\backup\Monthly\h%month%_%year%.zip -r -p -t c:\backup\Daily\h%month%*%year%.zip
---------------------------
Example 2 (run during every backup)
------------
cd\
cd c:\Program Files\Winzip
for /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (
set year=%%k
set month=%%i
set day=%%j
)
if %month%==1 set chk_day=31
if %month%==2 set chk_day=28
if %month%==3 set chk_day=31
if %month%==4 set chk_day=30
if %month%==5 set chk_day=31
if %month%==6 set chk_day=30
if %month%==7 set chk_day=31
if %month%==8 set chk_day=31
if %month%==9 set chk_day=30
if %month%==10 set chk_day=31
if %month%==11 set chk_day=30
if %month%==12 set chk_day=31
if chk_day==day do (
wzzip c:\backup\Monthly\h%month%_%year%.zip -r -p -t c:\backup\Daily\h%month%*%year%.zip
)
----------------------------
The above batch file will NOT handle leap years. That will require additional calculations on the year. Also, the "set /a" command is only available on windows 2000, XP and 2003. If you are NOT running one of the above OS's, you will have to run the script manually.
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2004 05:12 PM
07-12-2004 05:12 PM
Re: Monthly Backups....dos style =)
if chk_day==day do (
wzzip c:\backup\Monthly\h%month%_%year%.zip -r -p -t c:\backup\Daily\h%month%*%year%.zip
)
Should be:
if %chk_day%==%day% do (
wzzip c:\backup\Monthly\h%month%_%year%.zip -r -p -t c:\backup\Daily\h%month%*%year%.zip
)
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2004 02:17 AM
07-13-2004 02:17 AM
Re: Monthly Backups....dos style =)
Thanks for this. I just tried it and it ran very quickly. It turned out that no zip file was made. Anyway thanks for the reply and the work done on this.
Monty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2004 04:08 AM
07-13-2004 04:08 AM
Re: Monthly Backups....dos style =)
If so, then it won't create a zip file until the last day of the month.
The design was to allow you to run it during the month in your standard backup script, but at the end of the month (when chk_day = the last day of the month 30,31, etc) that a complete Monthly backup file would be created, containing ALL of the previous zip file backups from the entire month.
This also assumes that a "monthly" folder had been created at c:\backup\monthly to contain the zip file. If c:\backup\monthly does not exist, then at the end of the month, this script will fail with a file not found error, or something like it.
Make more sense?
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2004 04:14 AM
07-13-2004 04:14 AM
Re: Monthly Backups....dos style =)
Monty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2004 05:42 PM
07-13-2004 05:42 PM
Re: Monthly Backups....dos style =)
Just change the wzzip line to point back to your data folder on H:\ as it was originally.
if %chk_day%==%day% do (
wzzip c:\backup\Monthly\h%month%_%year%.zip -r -p -t h:\*.*
)
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2004 09:26 AM
07-14-2004 09:26 AM
Re: Monthly Backups....dos style =)
Sorry i was tied up in a work and not able to post the script faster...
Here it is now..
copy the below code to some filename.wsf for ex., c:\copyfiles.wsf
<script language="VBScript">
dim FSO
dim objsourcefolder
dim filecollection
dim filepath
dim oWS
dim Lastmonth
dim returncode
dim scmd
folder_path="h:\"
Set FSO = CreateObject("Scripting.FileSystemObject")
set oWS = CreateObject("Wscript.Shell")
Set objSourceFolder = FSO.GetFolder(folder_path)
Set fileCollection = objSourceFolder.files
For Each filePath in fileCollection
Lastmonth = CInt(DateDiff("m",filePath.DateLastModified,Now))
scmd = "c:\Program Files\Winzip\wzzip c:\backup\Daily\h" & month(now) & day(now) & year(now) & ".zip -r -p -t "
If Lastmonth = 1 Then
scmd = scmd & folder_path & filepath.name
'WScript.Echo scmd
returnCode = oWS.Run(scmd, 0, true)
End If
next
dim subfolderscoll
dim subfol
set subfolderscoll = objsourcefolder.subfolders
for each subfol in subfolderscoll
Set fileCollection = subfol.files
For Each filePath in fileCollection
Lastmonth = CInt(DateDiff("m",filePath.DateLastModified,Now))
scmd = "c:\Program Files\Winzip\wzzip c:\backup\Daily\h" & month(now) & day(now) & year(now) & ".zip -r -p -t "
If Lastmonth = 1 Then
scmd = scmd & folder_path & subfol.name & "\" & filepath.name
' WScript.Echo scmd
returnCode = oWS.Run(scmd, 0, true)
End If
next
next
</script>
run this script as
CScript.exe C:\copyfiles.wsf
Let me know how it goes..
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2004 09:36 AM
07-14-2004 09:36 AM
Re: Monthly Backups....dos style =)
Thanks again for all your work you guys =)
Totally appreciated!
Monty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2004 09:55 AM
07-14-2004 09:55 AM
Re: Monthly Backups....dos style =)
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\lovell.HMFH>Cscript.exe c:\backup\sys\copyfiles.wsf
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
c:\backup\sys\copyfiles.wsf(31, 2) (null): The system cannot find the file speci
fied.
Hi Ganesh. I just tried it, maybe I gave you the wrong information...or I tried to run it incorrectly. I copied this from the DOS window. Does the script file look for all files within the H: drive or is it looking through the already made daily zip files?
I will totally understand if you just want to drop this...sorry for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 02:32 AM
07-15-2004 02:32 AM
Re: Monthly Backups....dos style =)
I think the issue is the system did not take the long folder name..
change this statement in the file
scmd = "c:\Program files\Winzip\wzzip c:\backup\Daily\h" & month(now) & day(now) & year(now) & ".zip -r -p -t "
to
scmd = "c:\Progra~1\Winzip\wzzip.exe c:\backup\Daily\h" & month(now) & day(now) & year(now) & ".zip -r -p -t "
this statement is there 2 times.. so make sure u replace it in both the placess..
Test it out and let me if it works..
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 07:14 AM
07-15-2004 07:14 AM
Re: Monthly Backups....dos style =)
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\lovell.HMFH>CScript.exe c:\backup\sys\copyfile.wsf
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
c:\backup\sys\copyfile.wsf(31, 2) (null): The system cannot find the file specif
ied.
Hi Ganesh - I changed it to "~1" both places and it gave me this again. Do you think I'm giving you some wrong data, variables, etc.? Again, if you want to cut your losses I will more than understand. Thanks for all your time in this.
Monty =)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:40 AM
07-15-2004 09:40 AM
Re: Monthly Backups....dos style =)
The issue is here only
scmd = "c:\Progra~1\Winzip\wzzip.exe c:\backup\Daily\h" & month(now) & day(now) & year(now) & ".zip -r -p -t "
either the wzzip.exe directory is wrong or the path where it is going to create the zip file might be wrong
1) what is the path of wzzip.exe?
2) does c:\backup\Daily\ directory exists??
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:48 AM
07-15-2004 09:48 AM
Re: Monthly Backups....dos style =)
I'm hoping to write a zip file that searches all files on H: drive.
Hope I didn't throw a wrench in the gears.
Monty =)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 10:43 AM
07-15-2004 10:43 AM
Re: Monthly Backups....dos style =)
i want u to run this script
job debug="true">
<script language="VBScript">
dim FSO
dim objsourcefolder
dim filecollection
dim filepath
dim oWS
dim Lastmonth
dim returncode
dim scmd
folder_path="h:\"
Set FSO = CreateObject("Scripting.FileSystemObject")
set oWS = CreateObject("Wscript.Shell")
Set objSourceFolder = FSO.GetFolder(folder_path)
Set fileCollection = objSourceFolder.files
For Each filePath in fileCollection
Lastmonth = CInt(DateDiff("m",filePath.DateLastModified,Now))
scmd = "c:\Progra~1\Winzip\wzzip c:\backup\Daily\h" & month(now) & day(now) & year(now) & ".zip -r -p -t "
If Lastmonth = 1 Then
scmd = scmd & folder_path & filepath.name
WScript.Echo scmd
'returnCode = oWS.Run(scmd, 0, true)
End If
next
</script>
when it runs it will display a message box with the output of the scmd variable. This is the command which has to run to create the zipfile.
So copy that or note it down and run it from where u running the script. And tell me whether there were any errors. If there are any errors. Let me know..
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 03:25 AM
07-16-2004 03:25 AM
Re: Monthly Backups....dos style =)
Monty
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\lovell.HMFH>CScript.exe c:\backup\sys\test.wsf
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
c:\backup\sys\test.wsf(37, 4) Windows Script Host: The end tag does not have a
corresponding start tag : job
>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 03:28 AM
07-16-2004 03:28 AM
Re: Monthly Backups....dos style =)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 06:08 AM
07-16-2004 06:08 AM
Re: Monthly Backups....dos style =)
job debug="true">
Should be:
Correct the line, then rerun the script.
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 06:20 AM
07-16-2004 06:20 AM
Re: Monthly Backups....dos style =)
Monty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 06:22 AM
07-16-2004 06:22 AM
Re: Monthly Backups....dos style =)
Thanks!
Monty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 06:24 AM
07-16-2004 06:24 AM
Re: Monthly Backups....dos style =)
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\lovell.HMFH>CScript.exe c:\backup\sys\test.wsf
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
c:\Progra~1\Winzip\wzzip c:\backup\Daily\h7162004.zip -r -p -t h:\EFFE.DC5
c:\Progra~1\Winzip\wzzip c:\backup\Daily\h7162004.zip -r -p -t h:\sketchup.skb
c:\Progra~1\Winzip\wzzip c:\backup\Daily\h7162004.zip -r -p -t h:\sketchup.skp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 08:30 AM
07-16-2004 08:30 AM
Re: Monthly Backups....dos style =)
Sorry about that "<" missing in the latest script.. can u change wzzip to wzzip.exe in the scmd line. I think then it should work.
Thanks Jon for fixing the missing "<".
Ganesh