Skip to content

Commit

Permalink
Version 1.9.24
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed May 31, 2023
1 parent 0f023d1 commit 88ae845
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.9.24
---------
* Remove leftover pid files in /var/tmp during offline backup (#114)

Version 1.9.23
---------
* Code cleanups
Expand Down
2 changes: 1 addition & 1 deletion libvirtnbdbackup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

__version__ = "1.9.23"
__version__ = "1.9.24"
16 changes: 16 additions & 0 deletions libvirtnbdbackup/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@ def copy(args: Namespace, source: str, target: str) -> None:
log.warning("Remote copy from [%s] to [%s] failed: [%s]", source, target, e)


def remove(args: Namespace, file: str) -> None:
"""Remove file either locally or remote"""
try:
if args.sshClient:
args.sshClient.run(f"rm -f {file}")
else:
os.remove(file)
log.debug("Removed: [%s]", file)
except FileNotFoundError:
pass
except OSError as e:
log.warning("Failed to remove [%s]: [%s]", file, e)
except sshError as e:
log.warning("Remote remove failed: [%s]: [%s]", file, e)


def progressBar(total: int, desc: str, args: Namespace, count=0) -> tqdm:
"""Return tqdm object"""
return tqdm(
Expand Down
1 change: 1 addition & 0 deletions libvirtnbdbackup/processinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ class processInfo:
logFile: str
err: str
out: str
pidFile: str
2 changes: 1 addition & 1 deletion libvirtnbdbackup/qemu/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def run(cmdLine: List[str], pidFile: str = "", toPipe: bool = False) -> processI
else:
realPid = p.pid

process = processInfo(realPid, logFileName, err, out)
process = processInfo(realPid, logFileName, err, out, pidFile)
log.debug("Started [%s] process: [%s]", cmdLine[0], process)

return process
2 changes: 1 addition & 1 deletion libvirtnbdbackup/ssh/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def run(self, cmd: str, pidFile: str = "", logFile: str = "") -> processInfo:
pid = int(pidOut)
log.debug("PID: [%s]", pid)

return processInfo(pid, logFile, err, out)
return processInfo(pid, logFile, err, out, pidFile)

def disconnect(self):
"""Disconnect"""
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" "April 2023" "virtnbdbackup 1.9.23" "User Commands"
.TH VIRTNBDBACKUP "1" "April 2023" "virtnbdbackup 1.9.24" "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.35855\/\fP)
Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.51823\/\fP)
.TP
\fB\-n\fR, \fB\-\-noprogress\fR
Disable progress bar
Expand Down
2 changes: 1 addition & 1 deletion man/virtnbdmap.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 VIRTNBDMAP "1" "April 2023" "virtnbdmap 1.9.23" "User Commands"
.TH VIRTNBDMAP "1" "April 2023" "virtnbdmap 1.9.24" "User Commands"
.SH NAME
virtnbdmap \- map virtnbdbackup image files to nbd devices
.SH DESCRIPTION
Expand Down
4 changes: 2 additions & 2 deletions man/virtnbdrestore.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 VIRTNBDRESTORE "1" "April 2023" "virtnbdrestore 1.9.23" "User Commands"
.TH VIRTNBDRESTORE "1" "April 2023" "virtnbdrestore 1.9.24" "User Commands"
.SH NAME
virtnbdrestore \- restore utility for libvirt
.SH DESCRIPTION
Expand Down Expand Up @@ -40,7 +40,7 @@ Process only disk matching target dev name. (default: None)
Disable progress bar
.TP
\fB\-f\fR SOCKETFILE, \fB\-\-socketfile\fR SOCKETFILE
Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.35860\/\fP)
Use specified file for NBD Server socket (default: \fI\,/var/tmp/virtnbdbackup.51828\/\fP)
.TP
\fB\-r\fR, \fB\-\-raw\fR
Copy raw images as is during restore. (default: False)
Expand Down
3 changes: 3 additions & 0 deletions virtnbdbackup
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,9 @@ def backupDisk(
logging.info("Stopping NBD Service.")
lib.killProc(nbdProc.pid)

if args.offline is True:
lib.remove(args, nbdProc.pidFile)

if args.stdout is False:
if args.noprogress is True:
logging.info(
Expand Down

0 comments on commit 88ae845

Please sign in to comment.