Showing posts with label everyonei. Show all posts
Showing posts with label everyonei. Show all posts

Monday, March 19, 2012

BackUp Quastions

Hi everyone
I have the folowing situations with my backups.
With Database Maintenance Plan is created backup strategy. Full Backup
is performing every day at 1.00 am. And Romove files older than: is
checked on 2 days, and it's working fine.

I am interested how can i perform this action with tsql, without using
DMPlan.
I tryed this:
BACKUP DATABASE TEST TO DISK 'C:...' WITH INIT, RETAINDAYS = 2

I put this statement into job but it is not working. I tryed after that
with (WITH NOINIT) but in that case .bak file grow and files older than
2 days are not deleted.

How can i delete files older then 2 days.
Thanks

acko

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!"acko bogicevic" <aconi2002@.yahoo.com> wrote in message
news:408ccc86$0$200$75868355@.news.frii.net...
> Hi everyone
> I have the folowing situations with my backups.
> With Database Maintenance Plan is created backup strategy. Full Backup
> is performing every day at 1.00 am. And Romove files older than: is
> checked on 2 days, and it's working fine.
> I am interested how can i perform this action with tsql, without using
> DMPlan.
> I tryed this:
> BACKUP DATABASE TEST TO DISK 'C:...' WITH INIT, RETAINDAYS = 2
> I put this statement into job but it is not working. I tryed after that
> with (WITH NOINIT) but in that case .bak file grow and files older than
> 2 days are not deleted.
> How can i delete files older then 2 days.
> Thanks
> acko
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

RETAINDAYS means that the backup set cannot be overwritten for that number
of days - it does not remove backups. One way to do this in SQL is using a
process something like this:

1. Generate a different backup filename for each day, based on the date -
BACKUP will accept a variable for the destination file name
2. After running BACKUP, execute 'dir /b' with xp_cmdshell to get a list of
the files in your backup folder into a temp table
3. Using a cursor, parse the filenames in the table to get the date of each
backup
4. If a file is older than @.x days (compare using DATEDIFF()), then use
xp_cmdshell again to delete it

But this is quite awkward to do in SQL, and may become complicated when you
have different backup types, different folders for each database's backups
etc. It would be probably easier to write an external script using Perl,
VBScript etc. which uses the SQLDMO objects to do everything. Or perhaps a
combination of both - use a multi-step job, where some steps are external
scripts, and some are SQL commands.

Simon|||"Simon Hayes" <sql@.hayes.ch> wrote in message
news:408d4a4e$1_2@.news.bluewin.ch...
> "acko bogicevic" <aconi2002@.yahoo.com> wrote in message
> news:408ccc86$0$200$75868355@.news.frii.net...
> > Hi everyone
> > I have the folowing situations with my backups.
> > With Database Maintenance Plan is created backup strategy. Full Backup
> > is performing every day at 1.00 am. And Romove files older than: is
> > checked on 2 days, and it's working fine.
> > I am interested how can i perform this action with tsql, without using
> > DMPlan.
> > I tryed this:
> > BACKUP DATABASE TEST TO DISK 'C:...' WITH INIT, RETAINDAYS = 2
> > I put this statement into job but it is not working. I tryed after that
> > with (WITH NOINIT) but in that case .bak file grow and files older than
> > 2 days are not deleted.
> > How can i delete files older then 2 days.
> > Thanks
> > acko
> > *** Sent via Developersdex http://www.developersdex.com ***
> > Don't just participate in USENET...get rewarded for it!
> RETAINDAYS means that the backup set cannot be overwritten for that number
> of days - it does not remove backups. One way to do this in SQL is using a
> process something like this:
> 1. Generate a different backup filename for each day, based on the date -
> BACKUP will accept a variable for the destination file name
> 2. After running BACKUP, execute 'dir /b' with xp_cmdshell to get a list
of
> the files in your backup folder into a temp table
> 3. Using a cursor, parse the filenames in the table to get the date of
each
> backup
> 4. If a file is older than @.x days (compare using DATEDIFF()), then use
> xp_cmdshell again to delete it
> But this is quite awkward to do in SQL, and may become complicated when
you
> have different backup types, different folders for each database's backups
> etc. It would be probably easier to write an external script using Perl,
> VBScript etc. which uses the SQLDMO objects to do everything. Or perhaps a
> combination of both - use a multi-step job, where some steps are external
> scripts, and some are SQL commands.

I'm going to suggest a much easier and in my mind more robust way.

Use the backupfile, backupset, etc tables in the msdb database.

This will let you find the proper filenames, dates, etc.

> Simon

Sunday, March 11, 2012

Backup plan didnt remove the old files

Hello, everyone:
I have a backup plan that remove the old backup files more than two days. Last Monday, the SQL Server restart. Since that, the backup is fine, but it didn't remove the old backup files. Why and how to handle that? Thanks
ZYTIt happens. Manually delete them.|||If you used the database maintenance wizard to create the maintenance plan, check the log files (under %install directory%\MSSQL\LOGS) and look through the entries. There should be something in there to indicate why the files were not deleted.

Regards,

hmscott

Monday, February 13, 2012

backup job hang

hi,everyone!

I meet strange thing when I create a maintance job for backup all
database.
and this backup job just stands "Executing job step '(step 1)'" for a
very
long time .

SQL server startup account is this account for network bakcup

after I issue sp_databases sp, I found my full database size only 1GB,
and I found my backupfile is complete.

I view event log and Sql server Log and no found error!

why do it take so long time, but stands 'executing ' status and never
finish.

help me!

best regards!wyys.cn@.gmail.com wrote:

Quote:

Originally Posted by

hi,everyone!
>
I meet strange thing when I create a maintance job for backup all
database.
and this backup job just stands "Executing job step '(step 1)'" for a
very
long time .
>
>
SQL server startup account is this account for network bakcup
>
>
after I issue sp_databases sp, I found my full database size only 1GB,
and I found my backupfile is complete.
>
>
I view event log and Sql server Log and no found error!
>
>
why do it take so long time, but stands 'executing ' status and never
finish.
>
>
help me!
>
best regards!


Specifically, How long is a "long time"?

Did you view the maintenance plan history? What steps were executed?
Did each step compele successfully? How long did each step take?

I have seen problems where the backup step works but the delete old
backup step fails. It turned out we had pending patches on the server
and a reboot cleaned up the problem allowing the job to run cleanly all
the way through.

HTH -- Mark D Powell --

backup job hang

hi,everyone!
I meet strange thing when I create a maintance job for backup all
database.
and this backup job just stands "Executing job step '(step 1)'" for a
very
long time .
SQL server startup account is this account for network bakcup
after I issue sp_databases sp, I found my full database size only 1GB,
and I found my backupfile is complete.
I view event log and Sql server Log and no found error!
why do it take so long time, but stands 'executing ' status and never
finish.
help me!
best regards!Hi
Slow network? Any other activities during the BACKUP?
<wyys.cn@.gmail.com> wrote in message
news:1153878873.514675.134860@.m79g2000cwm.googlegroups.com...
> hi,everyone!
> I meet strange thing when I create a maintance job for backup all
> database.
> and this backup job just stands "Executing job step '(step 1)'" for a
> very
> long time .
> SQL server startup account is this account for network bakcup
> after I issue sp_databases sp, I found my full database size only 1GB,
> and I found my backupfile is complete.
> I view event log and Sql server Log and no found error!
> why do it take so long time, but stands 'executing ' status and never
> finish.
>
> help me!
> best regards!
>|||wyys.cn@.gmail.com wrote:
> hi,everyone!
> I meet strange thing when I create a maintance job for backup all
> database.
> and this backup job just stands "Executing job step '(step 1)'" for a
> very
> long time .
> SQL server startup account is this account for network bakcup
> after I issue sp_databases sp, I found my full database size only 1GB,
> and I found my backupfile is complete.
> I view event log and Sql server Log and no found error!
> why do it take so long time, but stands 'executing ' status and never
> finish.
>
> help me!
> best regards!
>
If you see this in Enterprise Manager, do you then remember to Refresh
the job status?
Regards
Steen Schlter Persson
Databaseadministrator / Systemadministrator|||nework speed is normal.
more strange thing,I found backup file is finish,but status is still
'Executing'
Uri Dimant =E5=86=99=E9=81=93=EF=BC=9A
[vbcol=seagreen]
> Hi
> Slow network? Any other activities during the BACKUP?
>
>
> <wyys.cn@.gmail.com> wrote in message
> news:1153878873.514675.134860@.m79g2000cwm.googlegroups.com...|||Click on Refresh in the EM
<wyys.cn@.gmail.com> wrote in message
news:1153897201.723900.209890@.75g2000cwc.googlegroups.com...
nework speed is normal.
more strange thing,I found backup file is finish,but status is still
'Executing'
Uri Dimant ':
[vbcol=seagreen]
> Hi
> Slow network? Any other activities during the BACKUP?
>
>
> <wyys.cn@.gmail.com> wrote in message
> news:1153878873.514675.134860@.m79g2000cwm.googlegroups.com...|||Is it trying to send an email at the end?
<wyys.cn@.gmail.com> wrote in message
news:1153897201.723900.209890@.75g2000cwc.googlegroups.com...
nework speed is normal.
more strange thing,I found backup file is finish,but status is still
'Executing'
Uri Dimant ':
[vbcol=seagreen]
> Hi
> Slow network? Any other activities during the BACKUP?
>
>
> <wyys.cn@.gmail.com> wrote in message
> news:1153878873.514675.134860@.m79g2000cwm.googlegroups.com...|||No,Never send email,
any ideas?,guy!
Greg D. Moore (Strider) wrote:[vbcol=seagreen]
> Is it trying to send an email at the end?
>
> <wyys.cn@.gmail.com> wrote in message
> news:1153897201.723900.209890@.75g2000cwc.googlegroups.com...
> nework speed is normal.
> more strange thing,I found backup file is finish,but status is still
> 'Executing'
>
> Uri Dimant ':
>|||i have refreshed staus, but it still stands 'executing',
I think it should have another cause.
Steen Persson (DK) wrote:
> wyys.cn@.gmail.com wrote:
> If you see this in Enterprise Manager, do you then remember to Refresh
> the job status?
>
> --
> Regards
> Steen Schl=FCter Persson
> Databaseadministrator / Systemadministrator