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
772af74c
Commit
772af74c
authored
16 years ago
by
intrigeri
Browse files
Options
Downloads
Patches
Plain Diff
sys: new lvm option to backup LVM metadata of every detected volume group
parent
36854a51
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ChangeLog
+2
-0
2 additions, 0 deletions
ChangeLog
examples/example.sys
+4
-0
4 additions, 0 deletions
examples/example.sys
handlers/sys.helper.in
+5
-1
5 additions, 1 deletion
handlers/sys.helper.in
handlers/sys.in
+74
-1
74 additions, 1 deletion
handlers/sys.in
with
85 additions
and
2 deletions
ChangeLog
+
2
−
0
View file @
772af74c
...
...
@@ -21,6 +21,8 @@ version 0.9.7 -- UNRELEASED
sys:
. New luksheaders option (default=disabled) to backup the Luks header
of every Luks device.
. New lvm option (default=disabled) to backup LVM metadata for every
detected volume group.
version 0.9.6 -- July 21, 2008
backupninja changes
...
...
This diff is collapsed.
Click to expand it.
examples/example.sys
+
4
−
0
View file @
772af74c
...
...
@@ -31,6 +31,8 @@
# and restore it later by running "dd if=luksheader.sda2.bin of=/dev/sda2"
# (MAKE SURE YOU PASS THE CORRECT DEVICE AS of= !!!)
#
# (6) LVM metadata for every detected volume group, if "lvm = yes"
#
# here are the defaults, commented out:
...
...
@@ -61,6 +63,8 @@
# the others being written to the same file, and then overwritten by the next.
# luksheadersfile = /var/backups/luksheader.__star__.bin
# lvm = no
# If vservers = yes in /etc/backupninja.conf then the following variables can
# be used:
# vsnames = all | <vserver1> <vserver2> ... (default = all)
This diff is collapsed.
Click to expand it.
handlers/sys.helper.in
+
5
−
1
View file @
772af74c
...
...
@@ -9,7 +9,8 @@ sys_wizard() {
"partitions"
"the partition table of all disks."
on
\
"sfdisk"
"use sfdisk to get partition information."
on
\
"hardware"
"detailed hardware information"
on
\
"luksheaders"
"Luks headers of all Luks partitions."
off
"luksheaders"
"Luks headers of all Luks partitions."
off
\
"lvm"
"LVM metadata for all volume groups."
off
[
$?
=
1
]
&&
return
;
result
=
"
$REPLY
"
packages
=
"packages = no"
...
...
@@ -17,6 +18,7 @@ sys_wizard() {
sfdisk
=
"dosfdisk = no"
hardware
=
"hardware = no"
luksheaders
=
"luksheaders = no"
lvm
=
"lvm = no"
for
opt
in
$result
;
do
case
$opt
in
'"packages"'
)
packages
=
"packages = yes"
;;
...
...
@@ -24,6 +26,7 @@ sys_wizard() {
'"sfdisk"'
)
sfdisk
=
"dosfdisk = yes"
;;
'"hardware"'
)
hardware
=
"hardware = yes"
;;
'"luksheaders"'
)
luksheaders
=
"luksheaders = yes"
;;
'"lvm"'
)
lvm
=
"lvm = yes"
;;
esac
done
get_next_filename
$configdirectory
/10.sys
...
...
@@ -33,6 +36,7 @@ $partitions
$sfdisk
$hardware
$luksheaders
$lvm
# packagesfile = /var/backups/dpkg-selections.txt
# selectionsfile = /var/backups/debconfsel.txt
...
...
This diff is collapsed.
Click to expand it.
handlers/sys.in
+
74
−
1
View file @
772af74c
...
...
@@ -30,6 +30,8 @@
# and restore it later by running "dd if=luksheader.sda2.bin of=/dev/sda2"
# (MAKE SURE YOU PASS THE CORRECT DEVICE AS of= !!!)
#
# (6) LVM metadata for every detected volume group, if "lvm = yes"
#
if
[
-f
/etc/debian_version
]
then
...
...
@@ -93,6 +95,10 @@ getconf DD `which dd`
getconf luksheaders no
getconf luksheadersfile
$parentdir
/luksheader.__star__.bin
getconf VGS
`
which vgs
`
getconf VGCFGBACKUP
`
which vgcfgbackup
`
getconf lvm no
getconf vsnames all
# If vservers are configured, check that the ones listed in $vsnames are running.
...
...
@@ -121,6 +127,17 @@ if [ "$luksheaders" == "yes" ]; then
fi
fi
if
[
"
$lvm
"
==
"yes"
]
;
then
if
[
!
-x
"
$VGS
"
]
;
then
warning
"can't find vgs, skipping backup of LVM metadata"
lvm
=
"no"
fi
if
[
!
-x
"
$VGCFGBACKUP
"
]
;
then
warning
"can't find vgcfgbackup, skipping backup of LVM metadata"
lvm
=
"no"
fi
fi
## PACKAGES ##############################
#
...
...
@@ -534,7 +551,6 @@ if [ "$hardware" == "yes" ]; then
fi
fi
## PARTITIONS #############################
# here we use sfdisk to dump a listing of all the partitions.
...
...
@@ -604,3 +620,60 @@ if [ "$luksheaders" == "yes" ]; then
fi
done
fi
## LVM ####################################
# returns 0 on success, 1 on error, 2 if not tried
# outputs error message if error, reason if not tried
function
doLvmBackup
()
{
local
lvmdir
=
"
$1
"
if
[
!
-d
"
$lvmdir
"
]
;
then
if
!
mkdir
"
$lvmdir
"
;
then
echo
"could not create
$lvmdir
"
return
2
else
info
"successfully created
$lvmdir
"
fi
fi
if
[
!
-w
"
$lvmdir
"
]
;
then
echo
"can not write to directory
$lvmdir
"
return
2
fi
debug
"Let's try to gather the list of LVM volume groups"
debug
"
$VGS
--options vg_name --noheadings | @SED@ 's/^[ ]*//' | @SED@ 's/[ ]*
$/
/' | tr '
\n
' ' '"
vgs
=
`
$VGS
--options
vg_name
--noheadings
| @SED@
's/^[ ]*//'
| @SED@
's/[ ]*$//'
|
tr
'\n'
' '
`
debug
"Let's try to backup LVM metadata for detected volume groups:
$vgs
"
debug
"
$VGCFGBACKUP
--file
\"
${
lvmdir
}
\"
/
\'
%s
\'
$vgs
"
output
=
`
$VGCFGBACKUP
--file
"
${
lvmdir
}
"
/
'%s'
$vgs
`
exit_code
=
$?
debug
$output
case
$exit_code
in
0
)
info
"LVM metadata was saved to
$lvmdir
for volume groups:
$vgs
"
return
0
;;
*
)
echo
"LVM metadata could not be saved for at least one of these volume groups:
$vgs
"
return
1
;;
esac
}
if
[
"
$lvm
"
==
"yes"
]
;
then
output
=
`
doLvmBackup
"
${
parentdir
}
/lvm"
`
exit_code
=
$?
case
$exit_code
in
0
)
# success. info message has already been displayed
true
;;
1
)
# error
fatal
"
$output
"
;;
2
)
# could not even try
fatal
"LVM metadata backup was not tried:
$output
"
;;
*
)
# should never happen
fatal
"Unhandled error (
$exit_code
) while trying to backup LVM metadata, please report a bug"
;;
esac
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