Backup & Restore

Physical Backups


Significance

A physical backup involves duplicating all the physical storage components, such as files and directories, of a specific table, database, or other objects within a database system. These components include essential elements like data files, configuration files, and log files, capturing the entire storage structure as it exists on the disk.

Compared to logical backups, which involve exporting data in a structured format, physical backups are generally more compact and quicker to execute. This makes them particularly well-suited for scenarios where large or critical databases must be backed up swiftly and efficiently.

Common Techniques

File-based Backups: This technique involves copying database files directly from disk to backup storage. It is a straightforward approach but may require downtime or database locking during backup operations.
This typically includes data files, control files, and archived redo logs.

Example: In an Oracle database environment, a file-based backup might involve copying the data files (.dbf files), control files (controlfile.ctl), and archived redo logs (*.arc) to a backup destination using operating system utilities like cp (copy) or rsync.

Block-level Backups: Block-level backups operate at a lower level, capturing data at the disk block level rather than file level. This technique allows for incremental backups, where only changed blocks are backed up, reducing backup time and storage requirements.

Example: In a PostgreSQL database, block-level backups can be achieved using tools like pg_basebackup or third-party solutions that utilize PostgreSQL’s write-ahead logging (WAL) mechanism to capture changed blocks since the last backup.

Online Backups: Online backups enable database backups to be performed while the database remains operational, minimizing downtime and disruptions to business operations.

Example: In a MySQL database, online backups can be achieved using tools like mysqldump for logical backups or Percona XtraBackup for physical backups. These tools allow backups to be taken without locking tables, ensuring that the database remains accessible to users during the backup process.

Snapshot Backups: Snapshot backups use storage snapshots to create point-in-time copies of the database. This technique provides a consistent view of the database without interrupting ongoing transactions.

This approach is sometimes used in the cloud by taking snapshots of Cloud based storage volumes, and restarting the database on a different VM.

Example: In a Microsoft SQL Server environment, snapshot backups can be created using storage technologies such as Storage Spaces Direct (S2D) or SAN/NAS-based snapshot solutions. These technologies leverage the storage infrastructure to create instant, space-efficient snapshots of database volumes.

Backup Compression: Compressing backup files reduces storage space requirements and improves backup efficiency without sacrificing data integrity.

Example: In a MongoDB database, backup compression can be enabled using built-in compression options in backup utilities like mongodump or by utilizing third-party backup solutions that offer compression features.

Best Practices

Regular Backup Schedule: Here a regular backup schedule is established based on business requirements and data sensitivity. Consider factors such as data volatility, recovery time objectives (RTO), and recovery point objectives (RPO).

Offsite Storage: Store backup copies in secure, offsite locations to protect against site-wide disasters such as fires, floods, or theft.

Backup Verification: Regularly test backup files so that we can ensure that they are valid files,thus enabling successful restoration. Verification helps identify any issues with backup processes or storage media before they become critical.

Retention Policies: Define retention policies for backup files based on compliance requirements, regulatory standards, and business needs. Retain backups for an appropriate duration to support data recovery and legal obligations.

Encryption: Implement encryption for backup data in transit as well as at rest to safeguard sensitive information from unauthorized access or data breaches.

Monitoring and Alerting: Here, monitoring and alerting mechanisms are set up to track backup performance, storage usage, and potential issues. Proactive monitoring helps identify and address backup failures or anomalies promptly.