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 →
- 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
- For databases, flush or use the DB's own tool first (
mysqldump --single-transaction,pg_basebackup), orfsfreezearound the snapshot. - 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.
More on Storage, disks and filesystems
You get paged at 3 AM: the root filesystem on a production server is at 98% and climbing. Walk through your response.BeginnerA new 200 GB EBS volume is attached to an EC2 instance. How do you make it usable and persistent across reboots?BeginnerThe `/var` LVM logical volume is nearly full and there is free space in the volume group. How do you grow it online?BeginnerThe volume group has no free space. You've been given a new disk. How do you add it to grow `/var`?IntermediateA cloud VM's root disk was enlarged from 30 GB to 80 GB in the console, but `df` still shows 30 GB. What do you do?BeginnerYou need to move a busy MySQL data directory from the root disk to a new, faster volume. Plan it.Intermediate