|
-
Feb 7th, 2022, 09:43 AM
#1
I did not know that SQL had a NUL: "disk device"
I just had to use this command to shrink a 350 GB log file!
Code:
BACKUP LOG Acctfiles TO DISK='NUL:'
DBCC SHRINKFILE ( Acctfiles_Log, 1)
NUL: - a null device. I feel like I'm back in my PDP/11 or VAX days!
It worked!
-
Feb 7th, 2022, 12:00 PM
#2
Re: I did not know that SQL had a NUL: "disk device"
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Feb 8th, 2022, 07:40 AM
#3
Re: I did not know that SQL had a NUL: "disk device"
 Originally Posted by szlamany
feel like I'm back in my PDP/11 or VAX days!
It worked!
NUL is valid DOS devics in Windows like COM1 and LPT1 and AUX. You cannot have files with these names too.
Backup to NUL is currently the only option available since TRUNCATE_ONLY option was dropped in sql2008.
Generally you never need to use it during normal operations as in FULL recovery mode you *have* to backup log or if you don’t plan to then just use SIMPLE recovery mode and be done with it. Using FULL but lazying on log backups is the only time backup to NUL might be needed but while rectifying laziness just switch to SIMPLE and spare the backup to NUL at all.
-
Feb 8th, 2022, 08:21 AM
#4
Re: I did not know that SQL had a NUL: "disk device"
 Originally Posted by wqweto
NUL is valid DOS devics in Windows like COM1 and LPT1 and AUX. You cannot have files with these names too.
Backup to NUL is currently the only option available since TRUNCATE_ONLY option was dropped in sql2008.
Generally you never need to use it during normal operations as in FULL recovery mode you *have* to backup log or if you don’t plan to then just use SIMPLE recovery mode and be done with it. Using FULL but lazying on log backups is the only time backup to NUL might be needed but while rectifying laziness just switch to SIMPLE and spare the backup to NUL at all.
Not my server - not my IT department unfortunately...
My web app was denying logins - LOG disk on the server was full. I found an old 6GB backup of something - deleted it, just to allow logins - before an entire college of student and faculty could not connect!
Then I went and found the SQL LOG file - it was 350GB! No place to do a proper backup to then shrink - and NUL: rescued the moment.
I don't like telling IT departments how to backup data. It is ultimately their responsibility.
And here I am getting in the middle of it anyway and cleaning up their mess, lol!
-
Feb 8th, 2022, 08:52 AM
#5
Re: I did not know that SQL had a NUL: "disk device"
Sorry but when consulting I always point out problems with the way a company is handling backups. Everything from not doing proper T-Log backups to relying on something like comvalt (pauses IO on the DB while doing its thing) or even just relying on SAN backup (coalescing same reason)
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 8th, 2022, 09:48 AM
#6
Re: I did not know that SQL had a NUL: "disk device"
Only once I suggested a shrink . They gave me the evil eye and that was it.
We are backing up everything properly every night. I think despite our issues, the file, backup storage of the company is at a very good level....
It may help that I'm not currently in charge of doing this. I would just have rar-ed everything
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|