Skip to content

Commit

Permalink
version 1.9.22
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Apr 2, 2023
1 parent fde22ae commit d61b0ee
Show file tree
Hide file tree
Showing 35 changed files with 152 additions and 141 deletions.
7 changes: 6 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.9.22
---------
* Code cleanups, pylint warning
* Update copyright stanca

Version 1.9.21
---------
* Code cleanups
Expand All @@ -10,7 +15,7 @@ Version 1.9.20

Version 1.9.19
---------
* Code cleanup: move some functions to seperate files.
* Code cleanup: move some functions to separate files.

Version 1.9.18
---------
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ machine, including logfiles that can be used for analyzing backup issues:

During backup `virtnbdbackup` attempts to freeze all file systems within the
domain using the qemu guest agent filesystem freeze and thaw functions. In
case no qemu agent is installed or filesystem freeze fails, a warning is issued
case no qemu agent is installed or filesystem freeze fails, a warning is shown
during backup:

```
Expand Down Expand Up @@ -968,8 +968,8 @@ See also: https://github.com/abbbi/virtnbdbackup/issues/8
The utility is provided "as is", i take no responsibility or warranty if you
face any issues recovering your data! The only way to ensure your backups are
valid and your backup plan works correctly is to repeatedly test the integrity
by restoring them! If you discover any issues, please do not hesitate to open
an issue.
by restoring them! If you discover any issues, please do not hesitate to report
them.

## Links

Expand Down
4 changes: 2 additions & 2 deletions libvirtnbdbackup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -15,4 +15,4 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

__version__ = "1.9.21"
__version__ = "1.9.22"
2 changes: 1 addition & 1 deletion libvirtnbdbackup/argopt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3
"""
Copyright (C) 2022 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/chunk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -107,12 +107,6 @@ def configLogger(
)


def partialBackup(args: Namespace) -> int:
"""Check for possible partial backup files"""
partialFiles = glob.glob(f"{args.output}/*.partial")
return len(partialFiles) > 0


def hasFullBackup(args: Namespace) -> int:
"""Check if full backup file exists in target directory"""
fullFiles = glob.glob(f"{args.output}/*.full.data")
Expand Down
19 changes: 0 additions & 19 deletions libvirtnbdbackup/common/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion libvirtnbdbackup/extenthandler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/extenthandler/extenthandler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/logcount.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from libvirtnbdbackup import output
from libvirtnbdbackup.virt.client import DomainDisk
from libvirtnbdbackup.common import common as lib
from libvirtnbdbackup import common as lib
from libvirtnbdbackup.qemu import util as qemu
from libvirtnbdbackup.qemu.exceptions import ProcessError
from libvirtnbdbackup.ssh.exceptions import sshError
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/nbdcli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/nbdcli/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/output/target.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
54 changes: 54 additions & 0 deletions libvirtnbdbackup/partialfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

import os
import glob
import logging
from argparse import Namespace

from libvirtnbdbackup import exceptions


log = logging.getLogger()


def _exists(args: Namespace) -> int:
"""Check for possible partial backup files"""
partialFiles = glob.glob(f"{args.output}/*.partial")
return len(partialFiles) > 0


def exists(args: Namespace) -> bool:
"""Check if target directory has an partial backup,
makes backup utility exit errnous in case backup
type is full or inc"""
if args.level in ("inc", "diff") and args.stdout is False and _exists(args) is True:
log.error("Partial backup found in target directory: [%s]", args.output)
log.error("One of the last backups seems to have failed.")
log.error("Consider re-executing full backup.")
return True

return False


def rename(targetFilePartial: str, targetFile: str) -> None:
"""After backup, move .partial file to real
target file"""
try:
os.rename(targetFilePartial, targetFile)
except OSError as e:
raise exceptions.DiskBackupFailed(f"Failed to rename file: [{e}]") from e
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2022 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/qemu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/qemu/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ProcessError,
)
from libvirtnbdbackup.output import openfile
from libvirtnbdbackup.common.processinfo import processInfo
from libvirtnbdbackup.processinfo import processInfo

log = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions libvirtnbdbackup/qemu/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -23,7 +23,7 @@
from argparse import Namespace

from libvirtnbdbackup.ssh.exceptions import sshError
from libvirtnbdbackup.common.processinfo import processInfo
from libvirtnbdbackup.processinfo import processInfo
from libvirtnbdbackup.qemu import command
from libvirtnbdbackup.virt.client import DomainDisk

Expand Down
52 changes: 38 additions & 14 deletions libvirtnbdbackup/sighandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,48 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import sys
from argparse import Namespace
from typing import Any
from libvirt import virDomain
from libvirtnbdbackup import virt
from libvirtnbdbackup import common as lib
from libvirtnbdbackup.processinfo import processInfo
from libvirtnbdbackup.qemu import util as qemu


def catch(
args: Namespace,
domObj: virDomain,
virtClient: virt.client,
log: Any,
signum: int,
_,
) -> None:
"""Catch signal, attempt to stop running backup job."""
log.error("Caught signal: %s", signum)
log.error("Cleanup: Stopping backup job")
if args.offline is not True:
virtClient.stopBackup(domObj)
sys.exit(1)
class Backup:
"""Handle signal during backup operation"""

@staticmethod
def catch(
args: Namespace,
domObj: virDomain,
virtClient: virt.client,
log: Any,
signum: int,
_,
) -> None:
"""Catch signal, attempt to stop running backup job."""
log.error("Caught signal: %s", signum)
log.error("Cleanup: Stopping backup job")
if args.offline is not True:
virtClient.stopBackup(domObj)
sys.exit(1)


class Map:
"""Handle signal during map operation"""

@staticmethod
def catch(nbdkitProcess: processInfo, device: str, blockMap, log, signum, _):
"""Catch signal, attempt to stop processes."""
log.info("Received signal: [%s]", signum)
qemu.util("").disconnect(device)
log.info("Removing temporary blockmap file: [%s]", blockMap.name)
os.remove(blockMap.name)
log.info("Removing nbdkit logfile: [%s]", nbdkitProcess.logFile)
os.remove(nbdkitProcess.logFile)
lib.killProc(nbdkitProcess.pid)
sys.exit(0)
2 changes: 1 addition & 1 deletion libvirtnbdbackup/sparsestream/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/sparsestream/streamer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
Copyright (C) 2020 Red Hat, Inc.
This program is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/sparsestream/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
Copyright (C) 2020 Red Hat, Inc.
This program is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/ssh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions libvirtnbdbackup/ssh/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2022 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -26,7 +26,7 @@
)

from libvirtnbdbackup.ssh import exceptions
from libvirtnbdbackup.common.processinfo import processInfo
from libvirtnbdbackup.processinfo import processInfo

log = logging.getLogger("ssh")

Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/virt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/virt/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from libvirtnbdbackup import output
from libvirtnbdbackup.virt import xml
from libvirtnbdbackup.output.exceptions import OutputException
from libvirtnbdbackup.common.common import defaultCheckpointName
from libvirtnbdbackup.common import defaultCheckpointName
from libvirtnbdbackup.exceptions import (
NoCheckpointsFound,
ReadCheckpointsError,
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/virt/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2021 Michael Ablassmeier <[email protected]>
Copyright (C) 2023 Michael Ablassmeier <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions man/virtnbdbackup.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.1.
.TH VIRTNBDBACKUP "1" "March 2023" "virtnbdbackup 1.9.21" "User Commands"
.TH VIRTNBDBACKUP "1" "March 2023" "virtnbdbackup 1.9.22" "User Commands"
.SH NAME
virtnbdbackup \- backup utility for libvirt
.SH DESCRIPTION
Expand Down Expand Up @@ -48,7 +48,7 @@ Backup only disk with target dev name (\fB\-i\fR vda)
Exclude disk(s) with target dev name (\fB\-x\fR vda,vdb)
.TP
\fB\-f\fR SOCKETFILE, \fB\-\-socketfile\fR SOCKETFILE
Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.3131\/\fP)
Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.65893\/\fP)
.TP
\fB\-n\fR, \fB\-\-noprogress\fR
Disable progress bar
Expand Down
Loading

0 comments on commit d61b0ee

Please sign in to comment.