Sub topic 1
What a server backup must achieve
Prerequisites
This chapter assumes you can log in to a Linux server over SSH with a key, use sudo, read a shell script, and find files under /etc, /home, and /var. You do not need prior backup experience.
The 3-2-1 rule and recovery goals
A backup must survive the failure it protects against. The 3-2-1 rule gives a simple target: keep three copies of your data, on two different types of storage, with one copy stored off site.
Two numbers define what a backup must achieve:
- Recovery point objective (RPO) is the most data you can afford to lose, measured in time. A daily backup gives an RPO of up to 24 hours.
- Recovery time objective (RTO) is how long a restore may take before the service must be running again.
restic or Borg: how to choose
restic and BorgBackup (Borg) both create encrypted, deduplicated backups. Choose restic when you want one binary that works with many storage backends, including object storage such as S3. Choose Borg when your storage is an SSH-accessible host and you want a mature, compact format. Both work well on Linux servers.
Repositories, snapshots, and deduplication
A repository is the storage area where a tool keeps all backup data. A snapshot (called an archive in Borg) is one backup run recorded at a point in time. Snapshots share data. Deduplication stores each unique chunk of data once, so an unchanged file costs almost no extra space in the next snapshot.
Installing and initializing a repository
Install the tool, point it at your repository, and create the repository. A password file stored with root-only permissions keeps the passphrase out of your shell history.
sudo apt install restic
sudo install -m 600 /dev/null /etc/restic/password
sudo editor /etc/restic/password # paste a long passphrase, then save
export RESTIC_REPOSITORY=sftp:[email protected]:/srv/restic/myserver
export RESTIC_PASSWORD_FILE=/etc/restic/password
restic initSending backups off the server
A backup stored only on the same disk fails with the server. The sftp: address above sends the repository to a second host over SSH, which satisfies the off-site copy.
Exercise
Exercise
A server is backed up once a day to a local disk only. Which 3-2-1 requirement is unmet, and what RPO does the setup give?
Show answer
The off-site copy is missing, and the protection covers 2 copies at most. The RPO is up to 24 hours, because the newest backup can be a day old.