Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ian Eiloart
Sympl
Commits
bafa7da6
Commit
bafa7da6
authored
May 26, 2010
by
Steve Kemp
Browse files
Merge
parent
3c9a6d6d
Changes
16
Hide whitespace changes
Inline
Side-by-side
backup/backup2l.conf
deleted
100644 → 0
View file @
3c9a6d6d
##################################################
# Configuration file for backup2l #
##################################################
# Define the backup2l version for which the configuration file is written.
# This way, future versions can automatically warn if the syntax has changed.
FOR_VERSION
=
1
.
4
##################################################
# Volume identification
# This is the prefix for all output files;
# multiple volumes can be handled by using different configuration files
VOLNAME
=
"all"
##################################################
# Source files
# List of directories to make backups of.
# All paths MUST be absolute and start with a '/'!
SRCLIST
=(/
etc
/
root
/
srv
/
home
/
var
/
mail
/
var
/
lib
/
usr
/
local
/
var
/
backups
/
mysql
)
# The following expression specifies the files not to be archived.
# See the find(1) man page for further info. It is discouraged to
# use anything different from conditions (e. g. actions) as it may have
# unforeseeable side effects.
# This example skips all files and directories with a path name containing
# '.nobackup' and all .o files:
SKIPCOND
=(-
path
"*.nobackup*"
-
o
-
name
"*.o"
-
name
"*~"
)
# If you want to exclude several directories use the following expression:
# SKIPCOND=(-path '/path1' -o -path '/path1/*' -o -path '/path2' -o -path '/path2/*')
# NOTE: If you do not have anything to skip, use:
# SKIPCOND=(-false) # "SKIPCOND=()" does not work
##################################################
# Destination
# Mount point of backup device (optional)
#BACKUP_DEV="/disk2"
# Destination directory for backups;
# it must exist and must not be the top-level of BACKUP_DEV
BACKUP_DIR
=
"/var/backups/localhost"
##################################################
# Backup parameters
# Number of levels of differential backups (1..9)
MAX_LEVEL
=
3
# Maximum number of differential backups per level (1..9)
MAX_PER_LEVEL
=
8
# Maximum number of full backups (1..8)
MAX_FULL
=
2
# For differential backups: number of generations to keep per level;
# old backups are removed such that at least GENERATIONS * MAX_PER_LEVEL
# recent versions are still available for the respective level
GENERATIONS
=
1
# If the following variable is 1, a check file is automatically generated
CREATE_CHECK_FILE
=
1
##################################################
# Pre-/Post-backup functions
# This user-defined bash function is executed before a backup is made
PRE_BACKUP
()
{
echo
" writing dpkg selections to /root/.dpkg-selections.log..."
dpkg
--
get
-
selections
|
diff
- /
root
/.
dpkg
-
selections
.
log
> /
dev
/
null
||
dpkg
--
get
-
selections
> /
root
/.
dpkg
-
selections
.
log
echo
" dumping databases"
for
i
in
/
var
/
lib
/
mysql
/*/;
do
name
=`
basename
$
i
`
# get username + password
user
=$(
grep
user
/
etc
/
mysql
/
debian
.
cnf
|
awk
'{print $3}'
|
head
-
n
1
)
pass
=$(
grep
pass
/
etc
/
mysql
/
debian
.
cnf
|
awk
'{print $3}'
|
head
-
n
1
)
# do the dump
mysqldump
--
user
=
"$user"
--
pass
=
"$pass"
$
name
|
gzip
> /
var
/
backups
/
mysql
/$
name
.
gz
done
}
#
# This user-defined bash function is executed after a backup is made
#
POST_BACKUP
()
{
# show the disk space taken
du
-
sh
/
var
/
backups
/
localhost
#
# backup to off-site - this will need to be uncommented to run
# and assumes your machine is called foo.vm.bytemark.co.uk with
# access to the space known as foo.backup.bytemark.co.uk.
#
# rsync --stats --delete --delete-during -qazr /var/backups/localhost/ foo.backup.bytemark.co.uk::foo/foo.vm/
#
#
}
##################################################
# Misc.
# Create a backup when invoked without arguments?
AUTORUN
=
0
# Size units
SIZE_UNITS
=
""
# set to "B", "K", "M" or "G" to obtain unified units in summary list
# Archive driver for new backups (optional, default = "DRIVER_TAR_GZ")
# CREATE_DRIVER="DRIVER_MY_AFIOZ"
##################################################
# User-defined archive drivers (optional)
# This section demonstrates how user-defined archive drivers can be added.
# The example shows a modified version of the "afioz" driver with some additional parameters
# one may want to pass to afio in order to tune the speed, archive size etc. .
# An archive driver consists of a bash function named
# "DRIVER_<your-driver-name>" implementing the (sometimes simple) operations "-test", "-suffix",
# "-create", "-toc", and "-extract".
# If you do not want to write your own archive driver, you can remove the remainder of this file.
# USER_DRIVER_LIST="DRIVER_MY_AFIOZ" # uncomment to register the driver(s) below (optional)
DRIVER_MY_AFIOZ
()
{
case
$
1
in
-
test
)
# This function should check whether all prerequisites are met, especially if all
# required tools are installed. This prevents backup2l to fail in inconvenient
# situations, e. g. during a backup or restore operation. If everything is ok, the
# string "ok" should be returned. Everything else is interpreted as a failure.
require_tools
afio
# The function 'require_tools' checks for the existence of all tools passed as
# arguments. If one of the tools is not found by which(1), an error message is
# displayed and the function does not return.
echo
"ok"
;;
-
suffix
)
# This function should return the suffix of backup archive files. If the driver
#ädoes not create a file (e. g. transfers the backup data immediately to a tape
# or network device), an empty string has to be returned. backup2l uses this suffix
# to select a driver for unpacking. If a user-configured driver supports the same
# suffix as a built-in driver, the user driver is preferred (as in this case).
echo
"afioz"
;;
-
create
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
# This function is called to create a backup file. The argument $3 is the full file
# name of the archive file including path and suffix. $4 contains a list of files
# (full pathname) to be backed up. Directories are not contained, they are handled
# by backup2l directly without using the driver. All output to stderr should be
# directed to stdout ("2>&1").
afio
-
Zo
-
G
9
-
M
30
m
-
T
2
k
$
3
< $
4
2
>&
1
# This line passes some additional options to afio (see afio(1)):
# '-G 9' maximizes the compression by gzip.
# '-M 30m' increases the size of the internal file buffer. Larger files have to
# be compressed twice.
# '-T 2k' prevents the compression of files smaller than 2k in order to save time.
;;
-
toc
)
# Arguments: $2 = BID, $3 = archive file name
# This function is used to validate the correct generation of an archive file.
# The output is compared to the list file passed to the '-create' function.
# Any difference is reported as an error.
afio
-
Zt
$
3
|
sed
's#^#/#'
# The sed command adds a leading slash to each entry.
;;
-
extract
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
# This function is called by backup2l's restore procedure for each archive.
# It is extremely important that only those files contained in $4 are restored.
# Otherwise it may happen that files are overwritten by incorrect (e. g. older)
# versions of the same file.
afio
-
Zinw
$
4
$
3
2
>&
1
;;
esac
}
##################################################
# More sample archive drivers (optional)
# This is an unordered collection of drivers that may be useful for you,
# either to use them directly or to derive own drivers.
# Here's a version of the standard DRIVER_TAR_GZ driver,
# modified to split the output archive file into multiple sections.
# (donated by Michael Moedt)
DRIVER_TAR_GZ_SPLIT
()
{
case
$
1
in
-
test
)
require_tools
tar
split
cat
echo
"ok"
;;
-
suffix
)
echo
"tgz_split"
;;
-
create
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
mkdir
-
p
${
3
}
tar
cz
-
T
$
4
--
no
-
recursion
|
split
--
bytes
=
725100100
- ${
3
}/
part_
;;
-
toc
)
# Arguments: $2 = BID, $3 = archive file name
cat
${
3
}/
part_
* |
tar
tz
|
sed
's#^#/#'
;;
-
extract
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
cat
${
3
}/
part_
* |
tar
xz
--
same
-
permission
--
same
-
owner
-
T
$
4
2
>&
1
;;
esac
}
# This driver uses afio and bzip2, where bzip2 is invoked by afio.
# (donated by Carl Staelin)
DRIVER_MY_AFIOBZ2
()
{
case
$
1
in
-
test
)
require_tools
afio
bzip2
echo
"ok"
;;
-
suffix
)
echo
"afio-bz2"
;;
-
create
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
afio
-
z
-
1
m
-
P
bzip2
-
Q
-
9
-
Z
-
M
50
m
-
T
1
k
- <$
4
>$
3
2
>&
1
# This line passes some additional options to afio (see afio(1)):
# '-P bzip2' utilizes bzip2 as an external compressor
# '-Q 9' maximizes the compression by bzip2.
# '-M 50m' increases the size of the internal file buffer. Larger files have to
# be compressed twice.
# '-T 1k' prevents the compression of files smaller than 1k in order to save time.
;;
-
toc
)
# Arguments: $2 = BID, $3 = archive file name
afio
-
t
-
Z
-
P
bzip2
-
Q
-
d
- <$
3
|
sed
's#^#/#'
# The sed command adds a leading slash to each entry.
;;
-
extract
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
afio
-
Zinw
$
4
-
P
bzip2
-
Q
-
d
- <$
3
2
>&
1
;;
esac
}
# This driver uses afio and bzip2, such that the I/O stream is piped through bzip2.
# (donated by Carl Staelin)
DRIVER_MY_AFIO_BZ2
()
{
case
$
1
in
-
test
)
require_tools
afio
bzip2
echo
"ok"
;;
-
suffix
)
echo
"afio.bz2"
;;
-
create
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
afio
-
o
- < $
4
|
bzip2
--
best
> $
3
2
>&
1
;;
-
toc
)
# Arguments: $2 = BID, $3 = archive file name
bzip2
-
d
< $
3
|
afio
-
t
- |
sed
's#^#/#'
# The sed command adds a leading slash to each entry.
;;
-
extract
)
# Arguments: $2 = BID, $3 = archive file name, $4 = file list file
bzip2
-
d
< $
3
|
afio
-
inw
$
4
-
2
>&
1
;;
esac
}
backup/debian/changelog
View file @
bafa7da6
bytemark-vhost-simple-backup (20
090901095954
) stable; urgency=low
bytemark-vhost-simple-backup (20
10:0525-1
) stable; urgency=low
*
Add /home + /var/lib to the directories which are backed up
.
*
Move to a modular configuration file
.
-- Steve Kemp <steve@bytemark.co.uk> Tue, 1 Sep 2009 09:59:54 +0000
bytemark-vhost-simple-backup (20090825172437) stable; urgency=low
* Ensure we keep a backup if we change the backup2l.conf file.
-- Steve Kemp <steve@bytemark.co.uk> Tue, 25 Jul 2009 17:25:37 +0000
bytemark-vhost-simple-backup (20090707153244) stable; urgency=low
* Per-Lenny vhost repository, rather than branches
-- Steve Kemp <steve@bytemark.co.uk> Tue, 7 Jul 2009 15:32:44 +0000
bytemark-vhost-simple-backup (20090522105210) stable; urgency=low
* New release for Lenny.
-- Steve Kemp <steve@bytemark.co.uk> Fri, 22 May 2009 10:52:10 +0000
-- Steve Kemp <steve@bytemark.co.uk> Tue, 25 May 2010 21:00:12 +0000
bytemark-vhost-simple-backup (20081110153344) stable; urgency=low
...
...
backup/debian/control
View file @
bafa7da6
...
...
@@ -14,4 +14,7 @@ Description: Automatically backup your files locally
for a period of one week.
.
This backup won't protect you against system failure, but will prevent
you from accidental deletions, etc.
\ No newline at end of file
you from accidental deletions, etc.
.
If you're running upon a Bytemark system this package will also configure
remote backups.
backup/debian/dirs
View file @
bafa7da6
var/backups/localhost
var/backups/mysql
usr/share/bytemark-vhost-simple-backup
usr/share/bug/bytemark-vhost-simple-backup
\ No newline at end of file
usr/share/bug/bytemark-vhost-simple-backup
etc/backup.d/
backup/debian/postinst
View file @
bafa7da6
#!/bin/sh
##
## The post-install script needs to do two things:
##
## 1. If this is a migration, then configure it.
##
## 2. Otherwise force a rebuild
##
###
set
-e
#
# Skip, if we are not in "configure" state
#
##
## Skip, if we are not in "configure" state
##
if
[
"
$1
"
!=
"configure"
]
;
then
echo
"I: Skipping configuration"
exit
0
fi
#
# If the has been edited locally save it away.
#
if
(
!
diff /etc/backup2l.conf /usr/share/bytemark-vhost-simple-backup/backup2l.conf 2>/dev/null
>
/dev/null
)
;
then
mv
/etc/backup2l.conf /etc/backup2l.conf.
$(
date
+%Y-%M-%d
)
##
## The backup2l configuration file.
##
conf
=
/etc/backup2l.conf
##
## If we're migrated then we'll have the file /etc/backup2l.conf
## be a symlink to the generated file.
##
## So we test to see if the file exists and is a symlink.
##
if
(
!
test
-e
$conf
-a
-h
$conf
)
;
then
echo
"UPGRADING"
#
# We know that the conf file isn't our expected symlink.
#
mv
$conf
$conf
.old
>
/dev/null 2>/dev/null
||
true
#
# Now link in the file with the generated one
#
ln
-s
/etc/backup.d/backup2l.conf
$conf
fi
#
#
Install our global file.
#
c
p
/
usr/share/bytemark-vhost-simple-backup/backup2l.conf /etc/
##
#
# Finally, regardless of whether we're upgrading or not, we
#
#
trigger a rebuild
#
#
c
d
/
etc/backup.d/
&&
make
#DEBHELPER#
...
...
backup/debian/rules
View file @
bafa7da6
...
...
@@ -25,10 +25,9 @@ install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
make
install
prefix=`pwd`/debian/bytemark-vhost-simple-backup
cp bug.reports `pwd`/debian/bytemark-vhost-simple-backup/usr/share/bug/bytemark-vhost-simple-backup/control
dh_
install
# Build architecture-dependent files here.
binary-arch: build install
...
...
backup/etc/backup.d/Makefile
0 → 100644
View file @
bafa7da6
conf
:=
backup2l.conf
conf_tmp
:=
$(conf)
.tmp
snippets_dir
:=
conf.d
snippets
:=
$(
shell
ls
$$
PWD/
$(snippets_dir)
/[0-9][0-9]-
*
.conf |
sort
)
all
:
$(conf)
$(conf_tmp)
:
Makefile $(snippets)
@
rm
-f
$(conf_tmp)
@
for
s
in
$(snippets)
;
do
\
echo
"# ------------------------------------------------------------------------------"
>>
$(conf_tmp)
;
\
echo
"#
$$
s"
>>
$(conf_tmp)
;
\
echo
"# ------------------------------------------------------------------------------"
>>
$(conf_tmp)
;
\
echo
>>
$(conf_tmp)
;
\
cat
$$
s
>>
$(conf_tmp)
;
\
done
@
echo
/usr/sbin/exim4
-bV
-C
$(exim4_conf_tmp)
>
/dev/null
$(conf)
:
$(conf_tmp)
@
mv
-fb
$(conf_tmp)
$(conf)
clean
:
@
rm
-f
$(conf)
.PHONY
:
clean
.PRECIOUS
:
$(conf)
backup/etc/backup.d/README
0 → 100644
View file @
bafa7da6
/etc/backup.d/
This directory is the root of the backup script used by the Bytemark Symbiosis
system.
The following directories are present:
pre-backup.d/
-> Every script in this directory is executed prior to a backup run.
post-backup.d/
-> Every script in this directory is executed after a backup run has completed.
conf.d/
-> The contents of this directory are concatenated together to form a
backup2l.conf file which is written to /etc/backup.d/backup2l.conf
backup/etc/backup.d/conf.d/00-header.conf
0 → 100644
View file @
bafa7da6
###
##
## This file is /etc/backup.d/backup2l.conf
##
## This file is generated by concatenating the contents of the directory /etc/backup.d/conf.d/
##
## Any local changes you make to this file will be lost.
##
## If you wish to update the generated file please create, or update, any file matching
## the pattern [0-9][0-9]-*.conf.
##
##
#####
backup/etc/backup.d/conf.d/10-directories.conf
0 → 100644
View file @
bafa7da6
##################################################
# Source files
# List of directories to make backups of.
# All paths MUST be absolute and start with a '/'!
SRCLIST
=(/
etc
/
root
/
home
/
var
/
mail
/
usr
/
local
)
# The following expression specifies the files not to be archived.
# See the find(1) man page for further info. It is discouraged to
# use anything different from conditions (e. g. actions) as it may have
# unforeseeable side effects.
# This example skips all files and directories with a path name containing
# '.nobackup' and all .o files:
SKIPCOND
=(-
path
"*.nobackup*"
-
o
-
name
"*.o"
)
# If you want to exclude several directories use the following expression:
# SKIPCOND=(-path '/path1' -o -path '/path1/*' -o -path '/path2' -o -path '/path2/*')
# NOTE: If you do not have anything to skip, use:
# SKIPCOND=(-false) # "SKIPCOND=()" does not work
##################################################
# Destination
# Mount point of backup device (optional)
#BACKUP_DEV="/disk2"
# Destination directory for backups;
# it must exist and must not be the top-level of BACKUP_DEV
BACKUP_DIR
=
"/disk2/backup"
backup/etc/backup.d/conf.d/20-variables.conf
0 → 100644
View file @
bafa7da6
##################################################
# Volume identification
# This is the prefix for all output files;
# multiple volumes can be handled by using different configuration files
VOLNAME
=
"all"
# Define the backup2l version for which the configuration file is written.
# This way, future versions can automatically warn if the syntax has changed.
FOR_VERSION
=
1
.
4
##################################################
# Backup parameters
# Number of levels of differential backups (1..9)
MAX_LEVEL
=
3
# Maximum number of differential backups per level (1..9)
MAX_PER_LEVEL
=
8
# Maximum number of full backups (1..8)
MAX_FULL
=
2
# For differential backups: number of generations to keep per level;
# old backups are removed such that at least GENERATIONS * MAX_PER_LEVEL
# recent versions are still available for the respective level
GENERATIONS
=
1
# If the following variable is 1, a check file is automatically generated
CREATE_CHECK_FILE
=
1
backup/etc/backup.d/conf.d/30-actions.conf
0 → 100644
View file @
bafa7da6
##################################################
# Pre-/Post-backup functions
# This user-defined bash function is executed before a backup is made
PRE_BACKUP
()
{
run
-
parts
/
etc
/
backup
.
d
/
pre
-
backup
.
d
/
}
# This user-defined bash function is executed after a backup is made
POST_BACKUP
()
{
run
-
parts
/
etc
/
backup
.
d
/
post
-
backup
.
d
/
}
backup/etc/backup.d/conf.d/40-misc.conf
0 → 100644
View file @
bafa7da6
##################################################
# Misc.
# Create a backup when invoked without arguments?
AUTORUN
=
0
# Size units
SIZE_UNITS
=
""
# set to "B", "K", "M" or "G" to obtain unified units in summary list
backup/etc/backup.d/conf.d/99-footer.conf
0 → 100644
View file @
bafa7da6
###
##
##
#####
backup/etc/backup.d/post-backup.d/.empty
0 → 100644
View file @
bafa7da6
backup/etc/backup.d/pre-backup.d/.empty
0 → 100644
View file @
bafa7da6
Write
Preview
Supports
Markdown
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