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! 2 4443
"acko bogicevic" <ac*******@yaho o.com> wrote in message
news:40******** *************@n ews.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" <sq*@hayes.ch > wrote in message
news:40******** **@news.bluewin .ch... "acko bogicevic" <ac*******@yaho o.com> wrote in message news:40******** *************@n ews.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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew E |
last post by:
I just took over DBA responsibilities for an Oracle 8i database
running on Linux. Although I've been working with relational
databases for some time, I'm a bit green on Oracle so forgive me.
My first task was to implement a backup strategy (currently there is
none). I did a great deal of research both on this board and using
the Oracle Press 8i handbook. I made a cold backup (with oracle
shutdown) and sucessfully moved it from my...
|
by: Thiko |
last post by:
Hi
I take one nightly full database backup at 02:00 and backup the
transaction log to one backup set every 15mins.
The commands to do this are as follows and are set up to run as
database jobs:
-- Database Backup
BACKUP DATABASE TO WITH NOINIT ,
|
by: acko bogicevic |
last post by:
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
|
by: nt |
last post by:
I am having a problem with a regular backup of an SQL Server (MSDE
2000) database to a local drive. I initiate the backup once a week, by
issuing the required T-SQL, via ADO. In this case, the T-SQL is:
BACKUP DATABASE GPRS_Dimensioning_Archive TO local_backup WITH
RETAINDAYS=21, NAME='GDA_20040706'
Note that "local_backup" is a file sitting on the same physical drive
as the database itself, and has > 80 GB free. It is not a RAID...
|
by: John Rajendran |
last post by:
Hi there,
I need to take a backup with the following scanerio in mind:
At T1 I take the FULL BACK UP of the database called BACK_1_FULL.BACK in
c:\
Then at T2 I would like to take only the differential BACKUP of the
Transaction log called BACK_1_TRANSLOG.BACK and at T3 I would like to
take
only the differential BACKUP of the Transaction log called
BACK_2_TRANSLOG.BACK. At T4 my system fails and I need to bring the
database
| |
by: Eric Herber |
last post by:
I've a question regarding db2 (V8.1) and database backups
going to a storage manager like TSM for example.
As I can see in the storage manager if I backup the complete
database over the TSM API (no tablespace backups) the backup
images is stored as a single backup object.
Later I will be able to restore the complete database from
this image and I will also be able to restore single tablespaces
from this backup image as long as I...
|
by: alex |
last post by:
Hi !
I couldn't make backups with our new system using db2 8.2.
Every time I trigger a backup I get this error message:
BACKUP DATABASE EBUERO2 ONLINE TO "/raid/backup/ebuero2/part1",
"/raid/backup/ebuero2/part10", "/raid/backup/ebuero2/part11",
"/raid/backup/ebuero2/part12", "/raid/backup/ebuero2/part13",
"/raid/backup/ebuero2/part14", "/raid/backup/ebuero2/part15",
"/raid/backup/ebuero2/part16", "/raid/backup/ebuero2/part17",
|
by: uthuras |
last post by:
Hi all,
I have DB2ESE version 8.1 with FP 4 on AIX 5.2. My database used to be
1.1TB. When the DB size is 1.1TB, it takes approximately 7 hours to
backup the entire database (online backup). The backup is directed to
disk and not tape.
Recently, we did data archival by purging some of the records. Now, the
size of the database is 500GB plus. That means, only data purged and we
never resize the tablespace. Therefore, the allocated...
|
by: Konstantin Andreev |
last post by:
Hello.
Some time ago I asked in this conference, - How to use an ONLINE BACKUP to restore database onto another system? - but got no answers. Therefore I can conclude it is not possible.
But... what can I do with "online backup", really ? What is it needed for ? I do not see any possibility to use this backup. Please, share your knowledge, if you can.
Yes, I've read that since version 8.2 there is an option "INCLUDE LOSG" for "online...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |