Interview Prep/Linux/Storage, disks and filesystems

You must take consistent backups of a filesystem that is constantly being written to. How?

IntermediateScenarioStorage, disks and filesystems
Answer

Situation read → Use point-in-time snapshots.

What I'd do →

  1. On LVM:
sudo lvcreate -s -n data_snap -L 10G /dev/vg0/data
sudo mount -o ro,nouuid /dev/vg0/data_snap /mnt/snap   # nouuid needed for XFS
sudo tar -czf /backup/data-$(date +%F).tar.gz -C /mnt/snap .
sudo umount /mnt/snap && sudo lvremove -y /dev/vg0/data_snap
  1. For databases, flush or use the DB's own tool first (mysqldump --single-transaction, pg_basebackup), or fsfreeze around the snapshot.
  2. In the cloud, use EBS snapshots with application-consistent hooks.

Why → A snapshot gives a frozen view; copying a live directory produces a torn backup.

Interview tip → Mention that an LVM snapshot becomes invalid if its COW space fills, so size it for the change rate.

All Linux questions Roadmap: Linux

More on Storage, disks and filesystems