Skip to content

Include definitions #26

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ Usage

.. END AUTO-GENERATED USAGE

Building
--------

Example of how the binary is built, based on Debian Bullseye.

::

git clone https://github.com/milkey-mouse/backup-vm.git
cd backup-vm
sudo apt-get install python3-pip python3-setuptools python3-libvirt
python3 setup.py build
sudo python3 setup.py install

::

The binary ``backup-vm`` will now exist in ``/usr/local/bin/``.

Installation
------------

Expand Down
21 changes: 21 additions & 0 deletions backup_vm/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import os.path
import sys
import subprocess
import platform
import libvirt
from . import parse
from . import multi
Expand Down Expand Up @@ -46,8 +48,27 @@ def main():
for archive in args.archives:
archive.extra_args.append("--read-special")

# dump the xml before the snapshot so that we have the original disk devices
dom_xml = dom.XMLDesc(0)

with snapshot.Snapshot(dom, all_disks, args.progress), \
builder.ArchiveBuilder(disks_to_backup) as archive_dir:

f = open("origin.txt", "w")
f.write(platform.node())
f.close()

f = open(args.domain + ".xml", "w")
f.write(dom_xml)
f.close()

for disk in all_disks:
if disk in disks_to_backup and disk.type == "dev":
lv = subprocess.check_output(["/usr/sbin/lvdisplay", disk.path], text=True)
f = open( (disk.path + ".lv")[1:].replace("/", "--"), "w" )
f.write(lv)
f.close()

if args.progress:
borg_failed = multi.assimilate(args.archives, archive_dir.total_size)
else:
Expand Down