Automatic backup task

  • I recently completed setting up what I thought was a pretty good system for performing automated backups, but I can't get it to work. This isn't strictly SQL Server stuff, only partly, but there are a lot of sharp people on this forum - maybe someone here has some thoughts or experience with a similar problem.

    I'm using SQL Server 2008 R2 Express (paid version already sitting on my desk, installation in the task pipeline), so I wrote a T-SQL stored procedure that looks at the time and recent activity in the DB, and acts according to what it finds:

    - If it's the first fifteen minutes after 11pm and the database has changed that day, it does a full backup.

    - If it's between 6am and 11pm, and in the first fifteen minutes of the hour, and the database was changed sometime during the previous hour, it does a differential backup.

    - If it's between 6am and 11pm, sometime during the second, third or fourth fifteen minutes of the hour, and the database was changed sometime during the previous fifteen-minute block, it does a transaction log backup.

    This works fine.

    I then have a VBScript task that wipes all .bak files from the database folder, executes this procedure, then scans again for .bak files, zipping any that it finds to another folder, from where the .zip files are subsequently copied to further backup storage, both on and off site.

    This also works fine.

    What's not fine is the Windows Scheduled Task. I have this in the list of scheduled tasks to run every fifteen minutes, the schedule window gives the correct time for next scheduled run, the history window shows that it attempted the task, but nothing happens. The log shows only an "execution failed" error message, with no details. I've tried all the stuff I could find on the net about scheduled tasks, but nothing helps. A couple of times it seemed to be on the right track, but then suddenly stopped executing again, for no reason that I can see. I've tried setting execute with highest privelege, using my own admin account, using the system account, while logged on, while logged off, setting run regardless of logged-in status, wake machine to run task, putting the script name directly as a task, putting {full path}Wscript.exe as the task and the script name with full path as a parameter, including the folder in which to run - every option I can think of and every option I've seen posted somewhere as a posible solution - nothing has helped.

    The scheduled time comes and goes, the task history updates that it attempted execution, but zilch. And yet when I simply double-click the script to run it manually, it works perfectly. No parameters, no external information to confuse anything.

  • Did you try this link http://technet.microsoft.com/en-us/library/dd851678.aspx

  • Ignacio A. Salom Rangel (10/27/2012)


    Did you try this link http://technet.microsoft.com/en-us/library/dd851678.aspx

    No, that's something new, thank you. I'm not at work and have a slow connection here, but I'll try it as soon as I get in tomorrow.

  • Ignacio A. Salom Rangel (10/27/2012)


    Did you try this link http://technet.microsoft.com/en-us/library/dd851678.aspx

    Ok, unfortunately, that's not something I can work with. I am not a domain administrator. I have local admin privileges on the server, but not domain admin privileges.

  • pdanes (10/29/2012)


    Ignacio A. Salom Rangel (10/27/2012)


    Did you try this link http://technet.microsoft.com/en-us/library/dd851678.aspx

    Ok, unfortunately, that's not something I can work with. I am not a domain administrator. I have local admin privileges on the server, but not domain admin privileges.

    Did you give the user the "log on as batch job" permission on the server. Check http://social.technet.microsoft.com/Forums/en-US/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbe. Good luck!;-)

  • Okay, it's running. I'm not quite sure exactly what finally did the trick - I played with modifying the access privileges, as one of the articles suggested, and I restarted the task, which I hadn't always done before, as well as fiddled again with some of the account settings. Maybe a task restart is also necesary when something changes, although I would expect it would make the attempt and fail each time, if it was a privilege issue. Otherwise, it would indicate that the task was storing the privileges it read on the first attempt and never actually trying it again.

    Regardless, I now have a working configuration, so I can experiment with one setting at a time to find out what I actually need and what makes it fail again. Many thanks, Ignacio.

  • pdanes (10/30/2012)


    Okay, it's running. I'm not quite sure exactly what finally did the trick - I played with modifying the access privileges, as one of the articles suggested, and I restarted the task, which I hadn't always done before, as well as fiddled again with some of the account settings. Maybe a task restart is also necesary when something changes, although I would expect it would make the attempt and fail each time, if it was a privilege issue. Otherwise, it would indicate that the task was storing the privileges it read on the first attempt and never actually trying it again.

    Regardless, I now have a working configuration, so I can experiment with one setting at a time to find out what I actually need and what makes it fail again. Many thanks, Ignacio.

    Great to hear you got it working. It will be nice to share the exact solution once you are able to figure out what was the problem. I'm really happy to hear you manage to get it working. 😉

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply