How do you back up a database in SQL Server, PostgreSQL, or MySQL?
Short answer: SQL Server: To back up a database in SQL Server, you can use the BACKUP DATABASE command.
Explain a bit more
- Full Backup BACKUP DATABASE MyDatabase TO DISK = 'C:\Backups\MyDatabase.bak'; - Transaction Log Backup BACKUP LOG MyDatabase TO DISK = 'C:\Backups\MyDatabase_log.trn'; PostgreSQL: In PostgreSQL, you can use the pg_dump command for backing up the database. - Full Backup pg_dump mydatabase > /path/to/backup/mydatabase.sql For backing up with compression or other options: pg_dump -Fc mydatabase > /path/to/backup/mydatabase.dump For transactional backups, you can use WAL (Write-Ahead Logging) archiving, typically managed through archive_mode and archive_command settings in the postgresql.conf. MySQL: In MySQL, you can use the mysqldump command for backing up the database. - Full Backup mysqldump -u username -p mydatabase > /path/to/backup/mydatabase.sql For binary logging (transaction logs), MySQL uses binlog: - Enabling binary log [mysqld] log-bin=mysql-bin
Real-world example (ShopNest)
ShopNest’s SQL Server database stores customers, products, and orders. Good indexes and clear foreign keys keep checkout queries fast and safe.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png