Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 backup file is too big

Author  Topic 

Kuik Sok Ping
Starting Member

4 Posts

Posted - 2004-12-05 : 23:35:36
Hi...Im using the store procdure to backup my all database in SQL server..but the file after backup is too big..is it got any code in store procedure or ways to reduce teh file size of backup except using the winzip? Thanks

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-12-05 : 23:59:14
you can try shrinking the file before backing up

--------------------
keeping it simple...
Go to Top of Page

Kuik Sok Ping
Starting Member

4 Posts

Posted - 2004-12-06 : 00:08:23
how to shrinking the file?
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-12-06 : 00:12:33
are you referring to database or log files?
for database, use shrinkdatabase, for logs shrinkfile

or if you're not familiar with tsql, you can use enteprise manager, right click on database, all tasks, shrink database,

perform this during off peak hours for your production server

quote:

DBCC SHRINKFILE
Shrinks the size of the specified data file or log file for the related database.

Syntax
DBCC SHRINKFILE
( { file_name | file_id }
{ [ , target_size ]
| [ , { EMPTYFILE | NOTRUNCATE | TRUNCATEONLY } ]
}
)

Arguments
file_name

Is the logical name of the file shrunk. File names must conform to the rules for identifiers. For more information, see Using Identifiers.

file_id

Is the identification (ID) number of the file to be shrunk. To obtain a file ID, use the FILE_ID function or search sysfiles in the current database.

target_size

Is the desired size for the file in megabytes, expressed as an integer. If not specified, DBCC SHRINKFILE reduces the size to the default file size.

If target_size is specified, DBCC SHRINKFILE attempts to shrink the file to the specified size. Used pages in the part of the file to be freed are relocated to available free space in the part of the file retained. For example, if there is a 10-MB data file, a DBCC SHRINKFILE with a target_size of 8 causes all used pages in the last 2 MB of the file to be reallocated into any available free slots in the first 8 MB of the file. DBCC SHRINKFILE does not shrink a file past the size needed to store the data in the file. For example, if 7 MB of a 10-MB data file is used, a DBCC SHRINKFILE statement with a target_size of 6 shrinks the file to only 7 MB, not 6 MB.

EMPTYFILE

Migrates all data from the specified file to other files in the same filegroup. Microsoft® SQL Server™ no longer allows data to be placed on the file used with the EMPTYFILE option. This option allows the file to be dropped using the ALTER DATABASE statement.

NOTRUNCATE

Causes the freed file space to be retained in the files.

When NOTRUNCATE is specified along with target_size, the space freed is not released to the operating system. The only effect of the DBCC SHRINKFILE is to relocate used pages from above the target_size line to the front of the file. When NOTRUNCATE is not specified, all freed file space is returned to the operating system.

TRUNCATEONLY

Causes any unused space in the files to be released to the operating system and shrinks the file to the last allocated extent, reducing the file size without moving any data. No attempt is made to relocate rows to unallocated pages. target_size is ignored when TRUNCATEONLY is used.

Remarks
DBCC SHRINKFILE applies to the files in the current database. Switch context to the database to issue a DBCC SHRINKFILE statement referencing a file in that particular database. For more information about changing the current database, see USE.

The database cannot be made smaller than the size of the model database.

Use DBCC SHRINKFILE to reduce the size of a file to smaller than its originally created size. The minimum file size for the file is then reset to the newly specified size.

To remove any data that may be in a file, execute DBCC SHRINKFILE('file_name', EMPTYFILE) before executing ALTER DATABASE.

The database being shrunk does not have to be in single-user mode; other users can be working in the database when the file is shrunk. You do not have to run SQL Server in single-user mode to shrink the system databases.

For log files, SQL Server uses target_size to calculate the target size for the entire log; therefore, target_size is the amount of free space in the log after the shrink operation. Target size for the entire log is then translated to target size for each log file. DBCC SHRINKFILE attempts to shrink each physical log file to its target size immediately. If no part of the logical log resides in the virtual logs beyond the log file's target size, the file is successfully truncated and DBCC SHRINKFILE completes with no messages. However, if part of the logical log resides in the virtual logs beyond the target size, SQL Server frees as much space as possible and then issues an informational message. The message tells you what actions you need to perform to move the logical log out of the virtual logs at the end of the file. After you perform the actions, you can then reissue the DBCC SHRINKFILE command to free the remaining space. For more information about shrinking transaction logs, see Shrinking the Transaction Log.

Because a log file can only be shrunk to a virtual log file boundary, it may not be possible to shrink a log file to a size smaller than the size of a virtual log file, even if it is not being used. For example, a database with a log file of 1 GB can have the log file shrunk to only 128 MB. For more information about truncation, see Truncating the Transaction Log. For more information about determining virtual log file sizes, see Virtual Log Files.

Result Sets
This table describes the columns in the result set.

Column name Description
DbId Database identification number of the file SQL Server attempted to shrink.
FileId The file identification number of the file SQL Server attempted to shrink.
CurrentSize The number of 8-KB pages the file currently occupies.
MinimumSize The number of 8-KB pages the file could occupy, at minimum. This corresponds to the minimum size or originally created size of a file.
UsedPages The number of 8-KB pages currently used by the file.
EstimatedPages The number of 8-KB pages that SQL Server estimates the file could be shrunk down to.


Permissions
DBCC SHRINKFILE permissions default to members of the sysadmin fixed server role or the db_owner fixed database role, and are not transferable.

Examples
This example shrinks the size of a file named DataFil1 in the UserDB user database to 7 MB.

USE UserDB
GO
DBCC SHRINKFILE (DataFil1, 7)
GO





--------------------
keeping it simple...
Go to Top of Page

Kuik Sok Ping
Starting Member

4 Posts

Posted - 2004-12-06 : 02:10:45
im try to shrink the file through query Analiyze but it look tlike doesnt work...can u tell me wat file the DBCC shrinkdatabase ?is it the DBCC SHRINKDATABASE can shrink the database from my backup file ?
Go to Top of Page

scullee
Posting Yak Master

103 Posts

Posted - 2004-12-06 : 02:14:18
I think i understand your problem. Our backups files jumped over 4gb in the last 12 months and it meant we could no long zip them up with winzip to ship them around. (downloading 4gb over the net takes far too long)

You could use winrar or the newest version of winzip handles bigger files.

When our backup was 4gb, winzip compressed them to under 1gb
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-12-06 : 02:14:39
so you need to shrink the database before backing up not the other way around

quote:

you can try shrinking the file before backing up



--------------------
keeping it simple...
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-12-06 : 04:53:00
Set the BACKUP folder to Compressed (if you need to save disk space)

Or use SQL Litespeed

I've also heard of SQLZIP, but no idea what it is.

Kristen
Go to Top of Page

Kuik Sok Ping
Starting Member

4 Posts

Posted - 2004-12-06 : 06:23:02
what is SQL Litespeed?? after i use the srinking database , the backup file got decrese the size but still too big i need to decrese the backup file size again....got any tools or ways can introduce to me ?thanks a lot
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-12-06 : 09:50:54
"got any tools or ways can introduce to me"

Have a look for SQL Litespeed on Google

Kristen
Go to Top of Page
   

- Advertisement -