Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
backupninja
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Liberate
backupninja
Commits
a7bf628e
Commit
a7bf628e
authored
20 years ago
by
elijah
Browse files
Options
Downloads
Patches
Plain Diff
added scheduling (!) see readme.
parent
8fbbbbe8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README
+39
-0
39 additions, 0 deletions
README
backupninja
+97
-8
97 additions, 8 deletions
backupninja
changelog
+5
-2
5 additions, 2 deletions
changelog
etc/cron.d/backupninja
+2
-2
2 additions, 2 deletions
etc/cron.d/backupninja
with
143 additions
and
12 deletions
README
+
39
−
0
View file @
a7bf628e
...
@@ -28,6 +28,7 @@ The following options are available:
...
@@ -28,6 +28,7 @@ The following options are available:
-f <file> Use <file> for the main configuration instead of
-f <file> Use <file> for the main configuration instead of
/etc/backupninja.conf
/etc/backupninja.conf
CONFIGURATION FILES
CONFIGURATION FILES
===================
===================
...
@@ -77,6 +78,42 @@ For example:
...
@@ -77,6 +78,42 @@ For example:
pear = no thanks \
pear = no thanks \
i will not have a pear.
i will not have a pear.
SCHEDULING
==========
By default, each configuration file is processed everyday at 01:00 (1
AM). This can be changed by specifying the 'when' option in a config
file.
For example:
when = sundays at 02:00
when = 30th at 22
when = 30 at 22:00
when = everyday at 01 <-- the default
when = Tuesday at 05:00
A configuration file will be processed at the time(s) specified by the
"when" option. If multiple "when" options are present, then they all
apply. If two configurations files are scheduled to run in the same
hour, then we fall back on the alphabetical ordering specified above.
If two configurations files are scheduled close to one another in
time, it is possible to have multiple copies of backupninja running if
the first instance is not finished before the next one starts.
These values for 'when' are equivalent:
when = tuesday at 05:30
when = TUESDAYS at 05
These values for 'when' are invalid:
when = tuesday at 2am
when = tuesday at 2
when = tues at 02
REAL WORLD USAGE
REAL WORLD USAGE
================
================
...
@@ -101,6 +138,7 @@ the backup server must have root on the production server, and (3)
...
@@ -101,6 +138,7 @@ the backup server must have root on the production server, and (3)
rdiff-backup is more space efficient and featureful than using rsync +
rdiff-backup is more space efficient and featureful than using rsync +
hard links.
hard links.
SSH KEYS
SSH KEYS
========
========
...
@@ -117,6 +155,7 @@ user 'backup' on desthost without specifying a password.
...
@@ -117,6 +155,7 @@ user 'backup' on desthost without specifying a password.
Note: when prompted for a password by ssh-keygen, just leave it
Note: when prompted for a password by ssh-keygen, just leave it
blank by hitting return.
blank by hitting return.
INSTALLATION
INSTALLATION
============
============
...
...
This diff is collapsed.
Click to expand it.
backupninja
+
97
−
8
View file @
a7bf628e
...
@@ -133,6 +133,77 @@ function getconf() {
...
@@ -133,6 +133,77 @@ function getconf() {
eval
$1
=
'$ret'
eval
$1
=
'$ret'
}
}
#
# enforces very strict permissions on configuration file $file.
#
function
check_perms
()
{
local
file
=
$1
local
perms
=
`
ls
-ld
$file
`
perms
=
${
perms
:4:6
}
if
[
"
$perms
"
!=
"------"
]
;
then
fatal
"Configuration files must not be group or world readable! Dying on file
$file
"
fi
if
[
`
ls
-ld
$file
|
awk
'{print $3}'
`
!=
"root"
]
;
then
fatal
"Configuration files must be owned by root! Dying on file
$file
"
fi
}
# simple lowercase function
function
tolower
()
{
echo
"
$1
"
|
tr
[
:upper:]
[
:lower:]
}
# simple to integer function
function
toint
()
{
echo
"
$1
"
|
tr
[
:alpha:]
-d
}
#
# function isnow(): returns 1 if the time/day passed as $1 matches
# the current time/day.
#
# format is <day> at <time>:
# sunday at 16
# 8th at 01
# everyday at 22
#
# we grab the current time once, since processing
# all the configs might take more than an hour.
nowtime
=
`
date
+%H
`
nowday
=
`
date
+%d
`
nowdayofweek
=
`
date
+%A
`
nowdayofweek
=
`
tolower
"
$nowdayofweek
"
`
function
isnow
()
{
local
when
=
"
$1
"
set
--
$when
whendayofweek
=
$1
;
at
=
$2
;
whentime
=
$3
;
whenday
=
`
toint
"
$whendayofweek
"
`
whendayofweek
=
`
tolower
"
$whendayofweek
"
`
whentime
=
`
echo
"
$whentime
"
|
sed
's/:[0-9][0-9]$//'
`
if
[
"
$whendayofweek
"
==
"everyday"
]
;
then
whendayofweek
=
$nowdayofweek
fi
if
[
"
$whenday
"
==
""
]
;
then
if
[
"
$whendayofweek
"
!=
"
$nowdayofweek
"
]
;
then
whendayofweek
=
${
whendayofweek
%s
}
if
[
"
$whendayofweek
"
!=
"
$nowdayofweek
"
]
;
then
return
0
fi
fi
elif
[
"
$whenday
"
!=
"
$nowday
"
]
;
then
return
0
fi
[
"
$at
"
==
"at"
]
||
return
0
[
"
$whentime
"
==
"
$nowtime
"
]
||
return
0
return
1
}
#####################################################
#####################################################
## MAIN
## MAIN
...
@@ -195,6 +266,8 @@ getconf reportemail
...
@@ -195,6 +266,8 @@ getconf reportemail
getconf reportsuccess
yes
getconf reportsuccess
yes
getconf reportwarning
yes
getconf reportwarning
yes
getconf loglevel 3
getconf loglevel 3
getconf when
"Everyday at 01:00"
defaultwhen
=
$when
getconf logfile /var/log/backupninja.log
getconf logfile /var/log/backupninja.log
getconf SLAPCAT /usr/sbin/slapcat
getconf SLAPCAT /usr/sbin/slapcat
getconf RDIFFBACKUP /usr/bin/rdiff-backup
getconf RDIFFBACKUP /usr/bin/rdiff-backup
...
@@ -213,17 +286,12 @@ debug 1 "====== starting at "`date`" ======"
...
@@ -213,17 +286,12 @@ debug 1 "====== starting at "`date`" ======"
# by default, don't make files which are world or group readable.
# by default, don't make files which are world or group readable.
umask
077
umask
077
errors
=
0
for
file
in
$configdirectory
/
*
;
do
for
file
in
$configdirectory
/
*
;
do
[
-f
$file
]
||
continue
;
[
-f
$file
]
||
continue
;
perms
=
`
ls
-ld
$file
`
check_perms
$file
perms
=
${
perms
:4:6
}
if
[
"
$perms
"
!=
"------"
]
;
then
fatal
"Configuration files must not be group or world readable! Dying on file
$file
"
fi
if
[
`
ls
-ld
$file
|
awk
'{print $3}'
`
!=
"root"
]
;
then
fatal
"Configuration files must be owned by root! Dying on file
$file
"
fi
suffix
=
"
${
file
##*.
}
"
suffix
=
"
${
file
##*.
}
"
base
=
`
basename
$file
`
base
=
`
basename
$file
`
if
[
"
${
base
:0:1
}
"
==
"0"
]
;
then
if
[
"
${
base
:0:1
}
"
==
"0"
]
;
then
...
@@ -235,7 +303,28 @@ for file in $configdirectory/*; do
...
@@ -235,7 +303,28 @@ for file in $configdirectory/*; do
if
[
-e
"
$scriptdir
/
$suffix
"
]
;
then
if
[
-e
"
$scriptdir
/
$suffix
"
]
;
then
setfile
$file
setfile
$file
# skip over this config if "when" option
# is not set to the current time.
getconf when
"
$defaultwhen
"
IFS
=
$'
\t\n
'
for
w
in
$when
;
do
IFS
=
$'
\t\n
'
isnow
"
$w
"
ret
=
$?
IFS
=
$'
\t\n
'
if
[
$ret
==
0
]
;
then
debug 0
"skipping
$file
because it is not
$w
"
continue
else
debug 0
"running
$file
because it is
$w
"
continue
fi
done
IFS
=
$'
\t\n
'
echo_debug_msg
=
1
echo_debug_msg
=
1
# call the handler:
ret
=
`
(
.
$scriptdir
/
$suffix
$file
)
`
ret
=
`
(
.
$scriptdir
/
$suffix
$file
)
`
retcode
=
"
$?
"
retcode
=
"
$?
"
warnings
=
`
echo
$ret
|
grep
-e
"^Warning: "
|
wc
-l
`
warnings
=
`
echo
$ret
|
grep
-e
"^Warning: "
|
wc
-l
`
...
...
This diff is collapsed.
Click to expand it.
changelog
+
5
−
2
View file @
a7bf628e
version 0.3.5 -- Dec 16 2004
version 0.4 -- Dec 26 2004
added reportsuccess and reportwarning config options
added "when" option, so that all configs can specify when
they are to be run.
added reportsuccess and reportwarning config options
added .sys handler (hardware, packages, partitions).
version 0.3.4 -- Dec 8 2004
version 0.3.4 -- Dec 8 2004
fixed numerical variable quoting compatibility with older wc
fixed numerical variable quoting compatibility with older wc
...
...
This diff is collapsed.
Click to expand it.
etc/cron.d/backupninja
+
2
−
2
View file @
a7bf628e
# cron job for backupninja (
once a day
)
# cron job for backupninja (
every hour, on the hour
)
00
01
* * * root if [ -x /usr/sbin/backupninja -a -f /etc/backupninja.conf ]; then /usr/sbin/backupninja; fi
00
*
* * * root if [ -x /usr/sbin/backupninja -a -f /etc/backupninja.conf ]; then /usr/sbin/backupninja; fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment