Last active
October 15, 2016 16:28
-
-
Save pettazz/f8f0d1180cf2910e0a56150531b858bf to your computer and use it in GitHub Desktop.
Use LVM snapshots to create a nightly backup of the whole root disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
lvcreate -L2G -s -n /dev/alonso-vg/root-snapshot /dev/alonso-vg/root | |
dd if=/dev/alonso-vg/root-snapshot bs=16M status=progress | gzip -9 > /backup/alonso.nightly.gz | |
lvremove -f /dev/alonso-vg/root-snapshot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Has to be run as root. If using as a cron job, be sure to at least add /sbin to PATH for lvcreate/lvremove.