Many users assume that a backup is as simple as copying files to a second drive. However, this 'mirroring' approach fails to protect against several common risks. A simple copy does not protect against human error, such as accidentally formatting a drive or running a script that overwrites data. It also fails to account for 'bit rot'—the gradual corruption of data caused by magnetic particles shifting on hard drives or electricity leaking from NAND transistors in SSDs over time. To address these, a reliable system must ensure that data is not only copied but also preserved in a state that can be recovered even if the original source is compromised or corrupted.
Effective data protection relies on the concept of snapshots and Recovery Point Objectives (RPO). Unlike a mirror, which only shows the current state of a disk, a snapshot allows a user to 'travel back in time' to a previous state. This is critical for recovering from mistakes like accidental deletions. However, frequent snapshots create a significant storage burden. To manage this, systems can use Grandfather-Father-Son (GFS) rotation, where the frequency of snapshots increases as they get closer to the present day (e.g., daily backups kept for 14 days, weekly backups for 7 weeks, and monthly backups for a year). To further optimize storage and bandwidth, systems can use incremental backups and deduplication. Instead of storing identical copies of every file, these methods store only the changes between snapshots, referencing existing files via hard links. This approach is used by tools like rsnapshot to save storage and reduce the bandwidth required when transferring files to a second machine or a cloud service.
Despite these optimizations, building a custom backup solution involves significant technical hurdles, such as maintaining database consistency and handling cloud-specific limitations. For instance, databases may flush data to disk in batches, meaning a snapshot taken at the wrong millisecond could result in corrupted data; ensuring consistency often requires 'freezing' all I/O during the snapshot process. Additionally, cloud providers like Amazon S3 can impose high costs for uploading many small files and may strip away important file metadata. Because of these complexities, the author recommends using established tools like Borg or Restic, which abstract away these difficulties by handling encryption, chunk-level deduplication, and checksums. Ultimately, a backup is only functional if it can be successfully restored, making regular, verified restoration drills the final essential step in any data protection strategy.
