An existing SQL database can be completely backed up using the BACKUP DATABASE statement in SQL Server.
Syntax
BACKUP DATABASE databasename
TO DISK = 'filepath';
The SQL BACKUP WITH DIFFERENTIAL Statement
Only the database’s modified sections are backed up via a differential backup, which is different from a full database backup.
Syntax
BACKUP DATABASE databasename
TO DISK = 'filepath'
WITH DIFFERENTIAL;
BACKUP DATABASE Example
A complete backup of the current database “testDB” is created to the D drive using the SQL query that follows:
Example
BACKUP DATABASE testDB
TO DISK = 'D:\backups\testDB.bak';
Advice: Make sure to regularly backup your database to a drive other than the one you use for it. This way, in the event of a disk crash, your backup file and the database will not be lost.
BACKUP WITH DIFFERENTIAL Example
The database “testDB” is differentially backed up using the SQL query that follows:
Example
BACKUP DATABASE testDB
TO DISK = 'D:\backups\testDB.bak'
WITH DIFFERENTIAL;
A differential backup shortens the backup duration because it only backs up the modifications.