Why separate data types before backing up

A common error is to back up an entire root filesystem without exclusions. This pulls in package caches, swap files, and temporary directories that add size without adding value. Instead, decide what must be preserved and what the operating system or package manager can rebuild.

Configuration, application data, and replaceable software each require different handling during both backup and restore. Configuration changes are hard to recreate by hand. Application data often cannot be downloaded again. System packages and container images can usually be reinstalled from repositories.

  • Configuration lives mainly in /etc and selected files under /var/spool/cron or /root.
  • Application data includes web roots, user homes, and persistent volumes that hold unique content.
  • Replaceable items include package caches, Docker images, and anything listed in package selections that can be reinstalled.

Backing up configuration files

System configuration belongs in the backup because rebuilding it manually takes significant time. Focus on /etc for service settings, SSH keys, firewall rules, and certificate directories such as /etc/letsencrypt. Also capture user crontabs and any custom scripts stored under /root or /opt.

Package selection can be recorded as text files rather than copying the entire package cache. Commands such as apt-mark showmanual and dpkg --get-selections produce short lists that allow exact reproduction of the installed set on a fresh system.

  • Exclude /proc, /sys, /dev, /run, and /tmp because they contain kernel interfaces or transient data.
  • Exclude /var/cache and swap partitions because both can be regenerated.

Handling application data and databases

Application data must be backed up because it cannot be obtained from elsewhere. Typical locations include /var/www, /srv, /home, and Docker volumes. Flat files can usually be copied while services run, but databases require consistent dumps instead of raw file copies.

For databases, create a dump before the backup job runs. Store the dump alongside the file backup so that a restore brings both the schema and the data back together. Container compose files and environment files should also be included because they define how the application starts.

  • Dump MySQL or PostgreSQL data to a text file before the backup runs.
  • Include Docker volumes that contain user uploads or database files.
  • Skip Docker image layers under /var/lib/docker/overlay2 because images can be pulled again.

Identifying replaceable software and system components

The operating system and most packages can be reinstalled from official repositories. Therefore the backup does not need to contain the entire /usr or /var/lib directories. Recording the list of manually installed packages is enough to recreate the environment after a base install.

Container images follow the same rule. Only the compose files and the data volumes need protection. This approach keeps backup size manageable on small computers with limited storage or upload bandwidth.

  • Save package lists to /root/package-list.txt and /root/package-selections.txt.
  • Document any services running under /opt that are not managed by the package manager.

Running small monthly restore tests

A quick test verifies that files can be read from the repository. Create a temporary directory and restore only a single known file such as /etc/ssh/sshd_config. Compare the restored copy with the original to confirm they match. The same approach works with both restic and Borg, adjusting path syntax for each tool.

Also run the repository integrity check. Restic check verifies metadata quickly while the optional read-data-subset flag samples actual content. Borg check with verify-data performs a full data validation. A clean result shows no errors were found.

  • Test at least one file from each major category every month.
  • Record the time taken so you know the expected speed of a larger restore.

Performing a full yearly recovery drill

The small test proves files are readable but does not prove services will start. Once a year, provision a second empty server or virtual machine. Install the base system, apply the saved package list, connect to the backup repository, and restore the data. Import any database dumps and start the services. Time the entire process.

Note any missing pieces such as a certificate account key, a configuration file outside the backed-up paths, or database user permissions that were not captured. Update the backup plan with those items before the next cycle.

  • Keep the test system isolated to avoid conflicts with production.
  • Compare measured recovery time against your recovery time objective.