SQL Server backup file growing excessively - sql-server-2008

I am a software developer with not much expertise on SQL Server other than the basics.
On a daily basis, using the SQL Server Agent I back up the databases using the following command for each of the databases:
BACKUP DATABASE [DatabaseName]
TO DISK = N'D:\SQLBackups\DatabaseName.bak'
WITH NOFORMAT, NOINIT,
NAME = N'DatabaseName-Full Database Backup', SKIP, NOREWIND,
NOUNLOAD, STATS = 10
After running this command for several days, the size of the .bak file has reached 65 GB and growing.
The database files on the DATA directory are 0.92 GB for the .mdf and 1.2 GB for the .ldf one. And the database is set to full recovery mode.
Database engine is SQL Server 2008 R2 (version 10.50.2500.0)
If I create a full back using the SQL Server Management Studio interface, it occupies 0.93 GB.
Could somebody please explain how it is possible to reach such a big .bak file (65 GB) compared to manually creating a single full back up file?

The NOINIT option keeps appending data to the single .bak file. Use this statement to replace the existing .bak file:
BACKUP DATABASE [DatabaseName]
TO DISK = N'D:\SQLBackups\DatabaseName.bak'
WITH NOFORMAT, INIT,
NAME = N'DatabaseName-Full Database Backup', SKIP, NOREWIND,
NOUNLOAD, STATS = 10
All the details can be found in the official MSDN SQL Server Books Online documentation for the BACKUP DATABASE command....

Related

Unable to backup Mysql DB of size 30 GB | LAMP Stack

We have an ubuntu server having mysql installed. There is one DB whose size is 30 GB in production. This DB contains tables, views, and store procedures. We use MySQL script to execute the backup on the server. It works fine with the DB size of around 2-5 GB but when we run the same script on a 30 GB DB server it time out, sometimes it doesn't contain the store procedure in the DB backup. We try various updates in the script but didn't work.
Below is some error we received while taking its backup. 

Moving of large MySQL database from limited resource server

I have a Windows Server with MySQL Database Server installed.
Multiple databases exist among them, database A contains a huge table named 'tlog', size about 220gb.
I would like to move over database A to another server for backup purposes.
I know I can do SQL Dump or use MySQL Workbench/SQLyog to do table copy.
But due to limited disk storage in server (less than 50gb) SQL Dump is not possible.
The server is serving other works so basically the CPU & RAM is limited too. As a result, copy table without used up CPU & RAM is not possible.
Is there any other method that can do the moving of the huge database A over to another server please?
Thanks in advance.
You have a few ways:
Method 1
Dump and compress at the same time: mysqldump ... | gzip > blah.sql.gz
This method is good because chances are your database will be less than 50GB; as the database dump should be in ASCII; you're then compressing it on the fly.
Method 2
You can use slave replication; this method will require a dump of the data.
Method 3
You can also use xtrabackup.
Method 4
You can shutdown the database, and rsync the data directory.
Note: You don't actually have to shutdown the database; you can however do multiple rsyncs; and eventually nothing will change (unlikely if the database is busy; have to do during slow time); which means the database would have sync'd over.
I've had to do this method with fairly large PostgreSQL databases (1TB+). It takes a few rsyncs: but, hey; it's the cost of 0 down time.
Method 5
If you're in a virtual environment you could:
Clone the disk image.
If you're in AWS you could create an AMI.
You could add another disk and just sync locally; then detach the disk, and re-attach to the new VM.
If you're worried about consuming resources during the dump or transfer you can use ionice and renice to limit the priority of the dump/transfer.

saving SQL backup / dump on remote location

I would like to backup / dump my SQL (mysql - InnoDB or XtraDB depending if I will use Oracle's Mysql or MariaDB) database regularly.
Now, my hosting for the beginning will be 60 GB on SSD so it will soon fill with pictures and rows of tables, so the space is limited.
I want to dump my database safely and securely and non-intrusively (meaning not stressing out the server when doing it) and I NEED the file to be saved say on my local Win7 desktop, not on the server.
mysqldump does the trick, but fills up space on the server, and if my database will grow to 20 GB and I have 20 GB of pictures, the dump will fill out the remaining space or maybe would not fit at all.
so what are the ways to remotely save the dump (not on the same server) ?
i figure I can save / dump my tables from phpMyAdmin for sure, but when the tables get to 2 GB or 10 GB...don't know for sure if it works anymore (millions of rows)
thanks!
If you have remote access to your database server, this is only a matter of using mysqldump with the correct host option from a machine with enough disk space to hold your backup.
# if your database server has DNS name :
mysqldump -h my.database-server.local ...
# if you access your database server by its IPv4 address
mysqldump -h 192.168.0.22 ...
Or do I totally missed the point here?

SQL back up issues

I have been doing some research on best backup procedures for largish (27.678gb) MYSQL database tables.
Currently we are using a program called Rapidsync (which is a offsite backup tool) but it is slow and it locks the tables it's currently backing up therefore causing downtime/slowness of sql.
Our current server is running Windows 2008 r2 with SQL server 2008 (on the same box) also.
Hardware specs for the dedicated server are:
16gb Ram
CPU intel xeon E3-1230 V2 # 3.30GHz
1 TB hard drive
In terms of databases we have 58 in total varying in size in which some need to backed up weekly ideally or even daily.
Through a program we use called Navicat you can tunnel to a database using SSH and copy databases manually, is this a reliable and feasible option if we were to install it on our local machine and copy them across? Or would it be more secure/efficient to use SQL Dump maybe?
I hope I have given all of the necessary info but please do ask if you need to know more.
P.S Only free options at this moment as we are on a tight budget! :)
Thanks in advance
You mentioned SSH, so I suppose the backups can be done also on other server than the database server itself. For Unix, you can use great tool Percona xtrabackup, which is free and supports online (without locking) backup of InnoDB database files and also incremental backups. Maybe it is possible to compile it also on Windows (part of it is written in C, part in Perl).
So you can setup weekly full backup and daily incremental backups. The tool will keep track of which pages of the InnoDB datafile has been changed and will copy only those.

Move database to another server

I am using mysqldump to move my database to another sever. But database has tables with million of rows and mysql restore takes too long(4 houres).
is there any way I do this faster?
Here's the way I have done this in the past using mysql replication
Dump SQL on source machine with binary logging turned on (use the --master-data option) this will give you data at that point in time and allow you to import the data on your new server while new data is being populated on the old server.
after the import (4 hours you said?) then you can START SLAVE on the new server and the new server will replay the binary logs and catch up to the old server and keep in sync until the actual switchover happens.
How to setup mysql replication
Yes, you can kill the mysqld on the source server, once it is down you can copy the entire datadir to the new server and start both servers once copy is done.