In SQL Server, the BACKUP DATABASE statement is employed to generate a comprehensive backup of a pre-existing SQL database.
BACKUP DATABASE databasename TO DISK = ‘filepath‘; |
A differential backup selectively backs up the sections of the database that have been altered since the previous full database backup.
BACKUP DATABASE databasename TO DISK = ‘filepath‘ WITH DIFFERENTIAL; |
The following SQL statement generates a complete backup of the current database “testDB” to the D disk:
BACKUP DATABASE testDB TO DISK = ‘D:\backups\testDB.bak’; |
Tip: Always back up the database to a different drive than the actual database. Then, if you get a disk crash, you will not lose your backup file along with the database. |
The following SQL statement initiates a differential backup of the database “testDB”:
BACKUP DATABASE testDB TO DISK = ‘D:\backups\testDB.bak’ WITH DIFFERENTIAL; |
Tip: A differential back up reduces the back up time (since only the changes are backed up). |