+ Post New Thread
Results 1 to 2 of 2
How do you do....it? Thread, Backup SQL using Command Line in Technical; Hi, We would like to backup our ServiceDesk in case the unfortunate happens. I have setup a scheduled task which ...
  1. #1
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    642
    Thank Post
    118
    Thanked 89 Times in 73 Posts
    Rep Power
    78

    Backup SQL using Command Line

    Hi,

    We would like to backup our ServiceDesk in case the unfortunate happens.

    I have setup a scheduled task which uses the following:

    osql -S server.mydomain.com -U sqlbackup -Q "BACKUP DATABASE ServiceDesk TO DISK = 'N:\ServiceDesk Backup\ServiceDesk.bak'"

    Is there a way I can use the current date to rename the file? e.g ServiceDesk_101110.bak

    Thanks,

    Michael

  2. #2
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    642
    Thank Post
    118
    Thanked 89 Times in 73 Posts
    Rep Power
    78
    I managed to solve it in the end by creating a bat script and setting it as a scheduled task. Below is what I cobbled together, might come in handy for someone else.

    Code:
    @echo off
    
    cd C:\Program Files\Microsoft SQL Server\80\Tools\Binn
    
    osql -E -S 10.0.3.60 -Q "BACKUP DATABASE ServiceDesk TO DISK = 'C:\ServiceDesk Backup\ServiceDesk.bak'"
    
    cd "c:\serviceDesk Backup"
    
    for /f "tokens=1-4 delims=/ " %%b in ('date /t') do (set day=%%b& set month=%%c& set year=%%d)
    set jdate=%day%-%month%-%year%
    ren ServiceDesk.bak %jdate%.bak
    
    COPY /Y "C:\ServiceDesk Backup\%jdate%.bak" "\\storage\ServiceDesk Backup$\"

SHARE:
+ Post New Thread

Similar Threads

  1. esx command line help
    By ful56_uk in forum Thin Client and Virtual Machines
    Replies: 6
    Last Post: 17th February 2010, 05:04 PM
  2. NTBackup - Command Line
    By dave.81 in forum Windows
    Replies: 2
    Last Post: 7th May 2008, 09:46 AM
  3. Office Command Line ID
    By alan-d in forum How do you do....it?
    Replies: 4
    Last Post: 23rd April 2008, 10:51 AM
  4. Command LIne
    By wesleyw in forum Windows
    Replies: 4
    Last Post: 12th October 2006, 11:10 AM
  5. Command line installs? heeellllppp
    By contink in forum How do you do....it?
    Replies: 2
    Last Post: 2nd October 2006, 04:27 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •