-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mario Loderer
committed
Sep 25, 2023
0 parents
commit 9a49b33
Showing
29 changed files
with
9,543 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# | ||
# (c) Rene Hadler, iteas IT Services GmbH | ||
# [email protected] | ||
# www.iteas.at | ||
# | ||
|
||
import os | ||
import sys | ||
import re | ||
import subprocess | ||
|
||
if len(sys.argv) < 4 or len(sys.argv) > 5: | ||
print("Nicht genügend Argumente: %s <latest_backup_count> <proxmox_dump_dir> <backup_destination_dir>" % (sys.argv[0])) | ||
sys.exit(0) | ||
|
||
backup_count = int(sys.argv[1]) | ||
dump_dir = sys.argv[2] | ||
backup_dir = sys.argv[3] | ||
|
||
# Find unique ids | ||
id_list = [] | ||
re_id_match = re.compile(r"^vzdump\-(qemu|lxc)\-([0-9]{3})\-.*$") | ||
for file in os.listdir(dump_dir): | ||
res = re_id_match.search(file) | ||
if res != None: | ||
file_id = res.group(2) | ||
if file_id not in id_list: | ||
id_list.append(file_id) | ||
|
||
id_list = sorted(id_list) | ||
|
||
for id in id_list: | ||
fp = os.popen("ls -t %s/vzdump*%s*lzo | head -n%s " % (dump_dir, id, backup_count), "r") | ||
files = [os.path.basename(x).strip() for x in fp.readlines()] | ||
for file in files: | ||
cmd_cp = "rsync -av %s %s" % (dump_dir + "/" + file, backup_dir + "/.") | ||
print(cmd_cp) | ||
subprocess.call(cmd_cp, shell=True) |
Binary file not shown.
Oops, something went wrong.