Saturday, February 25, 2012

Backups

I need to restore a backup dbs from one SQL Server to another on a nightly
basis. We do our backups using a Maintenance Plan. The name of the backup
file is different every night as the backups of each db run at different
times. Is there a way to fix the name of the backup files so they don't
have a time element in the name? Is there a way to discover the name that
was used last?
BarrySet up a job to do the backup with T-SQL instead of using the maint plan.
<barryfz@.home.com> wrote in message
news:%23neDZcOnEHA.4004@.TK2MSFTNGP10.phx.gbl...
> I need to restore a backup dbs from one SQL Server to another on a nightly
> basis. We do our backups using a Maintenance Plan. The name of the backup
> file is different every night as the backups of each db run at different
> times. Is there a way to fix the name of the backup files so they don't
> have a time element in the name? Is there a way to discover the name that
> was used last?
> Barry
>|||The following is a TSQL command that will perform a full
database backup to the file specified in the DISK=parameter. You can schedule this backup in SQL Server
Agent.
Backup Database DataBaseName to
DISK='\\Server\ShareName\DataBaseName_Data.BAK' with
RetainDays=1, INIT, Description='Daily Backup Routine'
This is just a direction for you to take your research.
Test this process as well as your restore procedures
prior to putting this into production.
Good luck,
D2
>--Original Message--
>I need to restore a backup dbs from one SQL Server to
another on a nightly
>basis. We do our backups using a Maintenance Plan. The
name of the backup
>file is different every night as the backups of each db
run at different
>times. Is there a way to fix the name of the backup
files so they don't
>have a time element in the name? Is there a way to
discover the name that
>was used last?
>Barry
>
>.
>|||I had to do this for a file that was being sent through a firewall every
night via FTP. So I dynamically created the ftp script every night.
In your situation then in DOS do something like this
Create a batch file
SETLOCAL
SET File_Name=FOR /F "usebackq" %%x IN (`dir *.txt /b /od`) DO SET FILE_NAME=%%x
IF {%File_Name%}={} exit 1
COPY %File_Name% Z:\SomeFolderNamedWhatEveryYouLike
ENDLOCAL
The for loop is the interesting bit, it simply lists every txt file in
date order and assigns the name to a variable File_Name. The only issue
is for every txt file the variable is changed, so if there are 100 files
the loop goes around 100 times before it finds the correct name
Adrian
barryfz@.home.com wrote:
> I need to restore a backup dbs from one SQL Server to another on a nightly
> basis. We do our backups using a Maintenance Plan. The name of the backup
> file is different every night as the backups of each db run at different
> times. Is there a way to fix the name of the backup files so they don't
> have a time element in the name? Is there a way to discover the name that
> was used last?
> Barry
>|||Hi Barry,
As community members had provided sufficient information about the way of
backup, I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!
Sincerely yours,
Mingqing Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Introduction to Yukon! - http://www.microsoft.com/sql/yukon
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!

No comments:

Post a Comment