Created
April 24, 2019 11:27
-
-
Save flower1024/bf62d366fd3c792edaac4c2d21272068 to your computer and use it in GitHub Desktop.
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 | |
LVS="lv_os_win10" | |
LVS_TAR="lv_data lv_os_arch" | |
TARGET="/mnt/data/backup" | |
for LV in $LVS | |
do | |
echo creating snapshot $LV | |
lvcreate -L50G -s -n backup_$LV /dev/vg/$LV || continue | |
echo backup | |
dd if=/dev/vg/backup_$LV bs=1024 | pv -s `lvs /dev/vg/$LV -o LV_SIZE --noheadings --units b --nosuffix` | pigz -c -9 > $TARGET/$LV.gz | |
echo removing snapshot | |
lvremove /dev/vg/backup_$LV | |
echo ------------------------------------------------------- | |
done | |
for LV in $LVS_TAR | |
do | |
echo creating snapshot $LV | |
lvcreate -L50G -s -n backup_$LV /dev/vg/$LV || continue | |
echo mounting snapshoot | |
mkdir -p $TARGET/$LV | |
mount /dev/vg/backup_$LV $TARGET/$LV | |
echo backup | |
tar cf - $TARGET/$LV -P | pv -s $(du -sb $TARGET/$LV | awk '{print $1}') | pigz -c -9 > $TARGET/$LV.gz | |
echo removing snapshot | |
umount $TARGET/$LV | |
lvremove /dev/vg/backup_$LV | |
echo ------------------------------------------------------- | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment