Windows incremental backup script - windows

I'm from a linux background, and need to run an incremental backup script on windows. I already have a batch script which dumps my database into a file. What I'd like is to only keep backups for the last seven days in addition to one backup file per week for the last 4 weeks (for example). I presume it's possible to do something like this with the windows task scheduler and a clever batch script?
Thanks.

Take a look at DeltaCopy - rsync for Windows. It's free, and does a great job.

ntbackup is a builtin Windows XP tool that can perform scheduled incremental backup.

Related

how can I run a java program automaticlly

I have a java package,
I want to my program be runned every night at 0 o'clock automaticlly,
how can I do this work?
Generally you have 2 solutions:
Create application that runs your code every night, i.e. implement scheduling yourself. Obviously you can (and should) use tools that help you to do scheduling.
Use OS-specific tools. For example cron for unix and windows task scheduler for windows.
You can either schedule in your own OS. On *nix, there is cron. I'm not sure what is used in windows.
Or you can make your own java program schedule: on running it, it sets a times to execute your task in a specific time.
You could use a Thread.sleep() counting the time from now until midnight, but that's a poor-man's solution. Quartz is your man, as it works schedulling your tasks.
If you choose the schedulling path, you can't forget to run your application in the OS startup

Scripting for safe file backup under windows

I need to back up some large files that are being written to disk by a process. The process is perpetually running, and occasionally dumps large files that need to be moved over the network. Having the process do this itself is not an option, as the process locks out users whilst it is doing file dumps.
So, this runs under a windows machine, and as a primarily linux user, I am not entirely certain how to do this...
Under linux I would simply use a cron job in the folder (I know the glob that will match the output files), then check lsof, to ensure that the file is not being written to, such that I don't try to copy a partially complete file. Data integrity is critical, so I would normally md5 the files before and after the copy.
So I guess my question is -- how does one do this sort of stuff under windows? I feel like I am kneecapped from the start -- I can use python, but I can't emulate lsof, nor cron to do the task scheduling.
I tried looking at "handle" -- but it needs admin privelidges at execution time, which is also not an option. I can't run the backup process as an admin, it has to run with user privs.
Thanks..
Edit: I just realised I could keep the python instance running, with a sleep, so task scheduling is not a problem :)
For replacing cron you can use the "Task Scheduler" in windows to start your script every few minutes (or specific times).
For lsof the question was discussed here : How can I determine whether a specific file is open in Windows?

cronJob on windows

i wanna to create a cron job on windows that daily delete files from a specific folder.
how can i do this??
Thanks in advance
Use Schedule tasks in windows. Check here. You can use del command to remove one or more files. Put it inside a batch script and schedule it as a task.
You want Scheduled Tasks.
With Scheduled Tasks, you can schedule
any script, program, or document to
run at a time that is most convenient
for you. Scheduled Tasks starts every
time that you start Windows XP and
runs in the background, and it starts
each task that you schedule at the
time that you specify when you create
the task.
Edit your question if you specifically need help with the deleting files bit, but typing in help del at a command prompt should tell you everything you need to know.
I use Cron for Windows, it's very easy to use if you are familiar with cron from *nix

Cron-like system for Windows?

I'm looking for an equivalent to a Cron system for Windows. The idea is to able to schedule a trigger and monitor whether it has run successfully or not.
What the system need to do is the following:
It should be able to trigger Win32 COM objects and/or executables.
It should be able to trigger .NET COM objects and/or .NET executables.
It should be able to trigger scripts written in any language, either based on native framework (Python, Perl, Ruby) or based on the DLR (IronPython, Ruby.NET, whatever)
The scripts should range between simple scripts that take a few seconds to fairly heavy ones that can take up to half an hour.
The monitoring aspect is critical. So basically I'm looking for the following:
If the script or executable fails then an e-mail should be sent or some other notification mechanism.
Every trigger should be logged so that we can look back and see when the code has failed.
The failure should easily be traced either through some sort of debug output or stack trace.
Are there any Windows developers out there who have created such a system? I know in the UNIX world there is Cron but what about in the Windows world?
At command prompt type 'at'
> at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.
You should be able to use the scheduled task for all the above.
I would suggest looking at revised Task Scheduler 2.0 in Vista/Server 2008. It is much more powerful than 1.0 in previous versions of Windows, now able to
Event based triggers, e.g. every time an Application event code 1053 is caused
Triggers on failed tasks (the biggest addition for me)
More built in actions, such as sending emails instead of calling blat.exe
Looking over your list, I believe that everything you are looking for is already there.
Have you looked at Windows Scheduler? It seems to meet most, if not all, of your requirements, and is already included in the OS. You can find it documented at MSDN
If you want a script to "trigger Win32 COM objects and/or executables", "trigger .NET COM objects and/or .NET executables", log failures and notify of failures by email, that sounds to me like a job for PowerShell.
PowerShell doesn't have logging and emailing done for you, rather it's a programming language where you can log or send email (or whatever) fairly easily.
I have scheduled PowerShell scripts to run using the "at" / "Task Scheduler" service, with success. It's a good combination.
Take a look at nnCron. I'm using a Lite version. It has a unix crontab syntax. There is a log file but as for more advanced monitoring aspects, it's up to your script/application to provide details, eg. return Result code (that will be logged). nnCron Lite was the best cron clone for windows (free, no perl requirement, crontab, missed tasks, run as hidden window, set enviroment variable - useful for postgres "dump all" tool, etc.) that I found.
Have a look here: Cron for Windows. There also was some Cron-like software ported for (Free)DOS that should work on Windows, but I can't remember the name.
Have you tried JIT-Scheduler in combination with PowerShell?
http://shareme.com/download/jit-scheduler.html

How do you schedule a daily script run on Windows XP?

I wrote a script in Ruby. I'd like to run it every day at a certain time. How do you do that on a Windows XP system?
I poked around on the machine and discovered the "scheduled tasks" control panel, but it doesn't seem to have anything to do with running scripts, as far as I can tell from the options offered by the "wizard".
Scheduled Tasks. Sometimes, you have to make a batch file call the script, and schedule the batch.
say you have "script.vbs" you want to run, you will have to create this batch:
cscript script.vbs
cscript is the windows script host which interprets the vbs script. I'm sure ruby has something similar.
You can do it with scheduled tasks, just browse for the program or script you want to run if it isn't listed (in this case, the ruby interpreter I guess, and add the name of the script to run as an argument).
Use the Windows task scheduler.
Under Control Panel > Schedule Tasks.
You can set it up to run any application or file executable from the command line.
Update: (1/15/09)
A good point from Wouter van Nifterick, remember to take care that the process finishes before the next one runs (in comments).
This can be done by going into the advanced options and adjust the allowed amount of time the task may run.
If the task is already configured open it and click the Settings tab. At the top of this tab you will see a checkbox followed by 'Stop the task if it runs for:' then there are two text boxes to enter hours and minutes. If your script runs once a day you will want this set to 23 hours or so.
The 'at' command is a nice command line version of a scheduler.

Resources