Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
puppet-backupninja
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chris
puppet-backupninja
Commits
3ae5405f
Commit
3ae5405f
authored
Apr 17, 2015
by
Antoine Beaupré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor rdiff check to isolate in a reusable function
parent
d0da8bea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
28 deletions
+34
-28
files/checkbackups.pl
files/checkbackups.pl
+34
-28
No files found.
files/checkbackups.pl
View file @
3ae5405f
...
...
@@ -52,6 +52,39 @@ EOF
exit
();
}
sub
CheckRdiffBackups
{
my
(
$dir
,
$subdir
,
$optv
)
=
@_
;
$flag
=
"
$dir
/
$subdir
/rdiff-backup-data/backup.log
";
$type
=
"
rdiff
";
if
(
open
(
FLAG
,
$flag
))
{
while
(
<
FLAG
>
)
{
if
(
/StartTime ([0-9]*).[0-9]* \((.*)\)/
)
{
$last_bak
=
$
1
;
$extra_msg
=
'
[backup.log]
';
$opt_v
&&
print
STDERR
"
found timestamp $1 ($2) in backup.log
\n
";
}
}
if
(
!
$last_bak
)
{
$message
=
"
cannot parse backup.log for a valid timestamp
";
next
;
}
}
else
{
$opt_v
&&
print
STDERR
"
cannot open backup.log
\n
";
}
close
(
FLAG
);
foreach
my
$vserver_dir
(
@vserver_dirs
)
{
$vsdir
=
"
$dir
/
${subdir}$vserver_dir
";
if
(
opendir
(
DIR
,
$vsdir
))
{
@vservers
=
grep
{
/^[^\.]/
&&
-
d
"
$vsdir
/
$_
"
}
readdir
(
DIR
);
$opt_v
&&
print
STDERR
"
found vservers
$vsdir
:
@vservers
\n
";
closedir
DIR
;
}
else
{
$opt_v
&&
print
STDERR
"
no vserver in
$vsdir
\n
";
}
}
return
(
$message
,
$extra_msg
,
$last_bak
);
}
my
$backupdir
=
$opt_d
;
my
$crit
=
$opt_c
;
my
$warn
=
$opt_w
;
...
...
@@ -84,34 +117,7 @@ foreach $host (@hosts) {
# XXX: the backup type should be part of the machine registry
my
$last_bak
;
if
(
-
d
"
$dir
/rdiff-backup
")
{
$flag
=
"
$dir
/rdiff-backup/rdiff-backup-data/backup.log
";
$type
=
"
rdiff
";
if
(
open
(
FLAG
,
$flag
))
{
while
(
<
FLAG
>
)
{
if
(
/StartTime ([0-9]*).[0-9]* \((.*)\)/
)
{
$last_bak
=
$
1
;
$extra_msg
=
'
[backup.log]
';
$opt_v
&&
print
STDERR
"
found timestamp $1 ($2) in backup.log
\n
";
}
}
if
(
!
$last_bak
)
{
$message
=
"
cannot parse backup.log for a valid timestamp
";
next
;
}
}
else
{
$opt_v
&&
print
STDERR
"
cannot open backup.log
\n
";
}
close
(
FLAG
);
foreach
my
$vserver_dir
(
@vserver_dirs
)
{
$vsdir
=
"
$dir
/rdiff-backup
$vserver_dir
";
if
(
opendir
(
DIR
,
$vsdir
))
{
@vservers
=
grep
{
/^[^\.]/
&&
-
d
"
$vsdir
/
$_
"
}
readdir
(
DIR
);
$opt_v
&&
print
STDERR
"
found vservers
$vsdir
:
@vservers
\n
";
closedir
DIR
;
}
else
{
$opt_v
&&
print
STDERR
"
no vserver in
$vsdir
\n
";
}
}
my
(
$message
,
$extra_msg
,
$last_bak
)
=
CheckRdiffBackups
(
$dir
,
'
rdiff-backup
',
$opt_v
);
}
elsif
(
-
d
"
$dir
/dump
")
{
# XXX: this doesn't check backup consistency
$flag
=
"
$dir
/dump/
"
.
`
ls -tr
$dir
/dump | tail -1
`;
...
...
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