Site icon New Generation Enterprise Linux

Keep your backups consistent without pausing the app

Backup & Recovery (Rsync/Tar/Dd)

Keep your backups consistent without pausing the app

đź§© The Challenge

Backing up a live database directory is a recipe for disaster because the files change right under your nose while the archive is running. I’ve lost nights of sleep trying to restore a corrupted dump because the index file didn’t match the data rows.

đź’ˇ The Fix

Use a LVM snapshot to freeze the state of the filesystem at a specific point in time before you start your backup. You get a perfect, consistent image that doesn’t care if your web server is still hammering the disk.

lvcreate -L 5G -s -n backup_snap /dev/vg0/data
mount /dev/vg0/backup_snap /mnt/snapshot
tar -czf /backups/data_$(date +%F).tar.gz -C /mnt/snapshot .
umount /mnt/snapshot
lvremove -f /dev/vg0/backup_snap

⚙️ Why It Works

Because the snapshot works at the block level, it creates a copy-on-write image that records exactly what the disk looked like when you pulled the trigger. Everything after that moment gets written elsewhere, so your tarball remains rock solid.

🚀 Pro-Tip: Just make sure your volume group actually has enough free space to hold the snapshot, or it’ll drop the session the second your application writes a heavy log.

Linux Tips & Tricks | © ngelinux.com | 9/19/2026

0 0 votes
Article Rating
Exit mobile version