Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FeldHost Public Projects
OpenNebula 3PAR Backup
Commits
d917cf23
Commit
d917cf23
authored
Dec 26, 2019
by
Kristian Feldsam
Browse files
Prune old backups
Signed-off-by:
Kristián Feldsam
<
feldsam@gmail.com
>
parent
3a119997
Changes
1
Hide whitespace changes
Inline
Side-by-side
drivers/_3par.py
View file @
d917cf23
...
...
@@ -169,6 +169,13 @@ def backup_live(one, image, vm, vm_disk_id, verbose):
if
not
one
.
vm
.
disksnapshotdelete
(
vm
.
ID
,
vm_disk_id
,
snap_id
):
raise
Exception
(
'Can not delete snapshot! Check VM logs.'
)
# prune old backups
if
verbose
:
print
'Pruning old backups...'
result
=
borgprune
(
name
)
if
verbose
:
print
result
def
backup
(
image
,
verbose
):
# get source name and wwn
...
...
@@ -209,6 +216,13 @@ def backup(image, verbose):
print
'Unexporting volume %s from backup server...'
%
name
unexport_vv
(
name
,
config
.
EXPORT_HOST
)
# prune old backups
if
verbose
:
print
'Pruning old backups...'
result
=
borgprune
(
name
)
if
verbose
:
print
result
def
borgbackup
(
name
,
dev
,
size_mb
):
size
=
size_mb
*
1024
*
1024
...
...
@@ -216,4 +230,12 @@ def borgbackup(name, dev, size_mb):
try
:
return
subprocess
.
check_output
(
'dd if=%s bs=256K | pv -pterab -s %d | borg create --compression auto,zstd,3 %s::%s-{now} -'
%
(
dev
,
size
,
config
.
BACKUP_REPO
,
name
),
shell
=
True
)
except
subprocess
.
CalledProcessError
as
ex
:
raise
Exception
(
'Can not backup dev using borgbackup!'
,
ex
)
\ No newline at end of file
raise
Exception
(
'Can not backup dev using borgbackup!'
,
ex
)
def
borgprune
(
name
):
try
:
return
subprocess
.
check_output
(
'borg prune -v --list --stats --keep-daily=7 --keep-weekly=4 --keep-monthly=6 --prefix=%s %s'
%
(
name
,
config
.
BACKUP_REPO
),
shell
=
True
)
except
subprocess
.
CalledProcessError
as
ex
:
raise
Exception
(
'Can not run borg prune!'
,
ex
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment