-
-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup of KVM Virtual Machines on LVM with --read-special #1832
Comments
Well you could do something along the lines of (untested) echo "Backup `hostname`"
REPOSITORY=/media/vmbackup/server1/
LVPATH=/dev/vg_vmimages/
LVNAME=`lvs --noheadings -o lv_name | tr -d ' '`
backup_LV() {
echo "Backing up LV $1"
echo " => Creating snapshot $1-snapshot"
lvcreate --size 5120M --snapshot --name "$1-snapshot" $LVPATH$1
echo " => Creating archive"
SNAPSHOT=$LVPATH$1-snapshot
borg create -svp --list -C lz4 --read-special \
$REPOSITORY::`hostname`-`date +%Y-%m-%d` lvdisplay.txt $SNAPSHOT
# ^- can also use https://borgbackup.rtfd.io/en/latest/usage.html#borg-help-placeholders
echo " => Deleting snapshot"
lvremove -f $SNAPSHOT
echo "Done with LV $1"
}
for VM in $LVNAME;
do
backup_LV $VM
done
#delete all files which do not meet "keep-conditions"
borg prune --info --list $REPOSITORY --prefix `hostname`- \
--keep-daily=7 --keep-weekly=4 --keep-monthly=3 |
FWIW here's how I backup my KVM https://gist.github.com/milkey-mouse/b8cb865910b4d574d9f63ffcd8db09f5 |
Maybe everybody could check if above adds something to the already existing stuff there: https://github.com/borgbackup/community/ If so, add a link there, so we can close this issue. |
I am working on a more robust version of that script in Python (using the libvirt & borg APIs directly). When I finish it I will submit a PR to the community repo. |
I have a KVM Virtual Machine on LVM with two drives on separate logical volumes (LVs).
When I start my backup with borg I have first to create snapshots.
How do I handle that in a bash script?
First create snapshot of drive one. Than backup with borg. Delete snapshot drive one.
Second create snapshot of drive two. Than backup with borg. Delete snapshot drive two.
End of script.
In the following example the snapshots are all generated bevor backup with borg and deleted after.
What is the best (or only way) way to handle it?
Thank You
Michael
The text was updated successfully, but these errors were encountered: