SQL Backup Database
A database backup is a copy of the data that can be restored after deletion, corruption, deployment mistakes or server failure. The exact command depends on the database system, but the goal is always the same: make recovery possible before something goes wrong.
Important note
Backup syntax is not universal SQL. Each database engine has its own tools and permissions. Treat backup commands as administration tasks, test restores regularly and never assume a backup is useful until a restore has been verified.
Example: SQL Server
BACKUP DATABASE store
TO DISK = 'C:\backups\store.bak';
This creates a backup file for the store database. The database account must have permission to write to the target location.
What a good backup plan includes
- A regular schedule.
- Storage outside the primary server.
- Clear retention rules.
- Restore tests, not just backup files.
- Access control, because backups can contain the entire database.
Common mistakes
- Keeping the only backup on the same machine as the database.
- Backing up without testing restore.
- Forgetting that logs, users, extensions or server settings may also matter.
Related topics
Continue with SQL DROP DATABASE, SQL CREATE DATABASE and SQL Injection.