Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
awit-dbackup
debian-awit-dbackup
Commits
e41b950c
Commit
e41b950c
authored
Sep 11, 2014
by
Nigel Kukard
Browse files
Imported Upstream version 0.0.22
parent
5a8e5f45
Changes
11
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
e41b950c
commit
74d05964428e404cde70efe01f43426a2dcaed22
commit
e68ad14dafe6af0c8bf59551ddc68c0f9372d781
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Mon Jun 9 14:02:54
2014 +0000
Date:
Thu Sep 11 16:28:23
2014 +0000
Added watch and upstream key
Fixed escaping of newline \n
commit
4eb7a0c67aae0cbfbe43
04
3
75
a1b00f1d7efb9d7
commit
63c71b2ea15a46b2
0475
2cc314279d4e75eda2eb
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Mon Jun 9 13:59:13
2014 +0000
Date:
Thu Sep 11 16:24:25
2014 +0000
Bumped version
Don't depend on old virtual package
commit
24ff56c38b5ef624994fec7c9fce11083b19697
d
commit
0795dfeac60314d2df9e38a44381d24f09b1a5a
d
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Mon Jun 9 13:58
:4
9
2014 +0000
Date:
Thu Sep 11 14:45
:4
2
2014 +0000
Fixed up debian packaging
Cleand up output a bit
commit
c3d0601308d8db5f800452b95b
40
4
74
7ce2298b4
commit
473ede56e07961330547789cd039f27e
40
5
74
c45
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Mon Jun 9 13:53:14
2014 +0000
Date:
Thu Sep 11 14:45:29
2014 +0000
Updated copyright date
Syntax cleanup
commit 0
5a39fbaf37acbd54a4591f59e459c43ff176043
commit 0
4b8da4966320cc425fcda05df44ec1c3e8abe96
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Sun Feb 9
1
5
:3
5:47
2014 +0000
Date:
Thu Sep 11
1
4
:3
3:26
2014 +0000
Fixed whitespaces
Improved on manpage
commit 669a63066152778c51897c34a2a38f8254cf76a0
Merge: af2ff41 6ae1e22
commit d18b82094db5866ae73f1fb53baa6db2137397bd
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Mon Oct 28 10:53:58
201
3
+0000
Date:
Thu Sep 11 08:15:30
201
4
+0000
Merge tag 'v0.0.20' into v0.0.x
Fix download location
commit
6ae1e22622150d406f49c06174a40602b2efe8cd
commit
574d60e240d8cbbfabef4b7a1dc3fbe48d9235df
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Sat Oct 26 19:34:46
201
3
+0000
Date:
Thu Sep 11 07:54:09
201
4
+0000
Bumped version
Commented on the install of the script
commit 9e16e3c034e63f8dd2f05872744aaedeef92d32d
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Thu Sep 11 07:28:28 2014 +0000
Cleaned up manpage generation
commit cbf207c05f74b1babf28e6d8f37ae566f1efe953
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Thu Sep 11 07:25:29 2014 +0000
Refined copyright tags and added upstream-contact
commit f16912c4d46c22f02d5e89f491960fd800c3844b
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Thu Sep 11 07:20:04 2014 +0000
Fixed plzip and pdlzip mixup
commit 60f00375c9686801262e51fc2974fc9d0bf6aacc
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 07:15:08 2014 +0000
Don't use bareword filehandles
commit ebac439a558ebe2ad6ef71cd9220936224e7bc0a
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 07:09:17 2014 +0000
Cosmetic syntax fixups
commit d2298f0b392e95479e0ce7a6aa7a93710239e866
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 07:08:55 2014 +0000
Don't use bareword file handles
commit 114d194d150bf8265f22c06bbe9b1e55f8347de9
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 07:08:15 2014 +0000
Check compression program exists
commit 90b994b8dba9752836d75dd685192404a0dcb09d
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 07:07:37 2014 +0000
Make sure the config file is not mandatory
commit c08178a6bd75d0380a3da3c582bb1c1cc4fb7853
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 07:06:28 2014 +0000
Added support for lzma (.lz) backup format
commit ed864216beba5966e37d00e2a10fcc0fa488bde6
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Fri Jul 11 06:27:18 2014 +0000
Code comment & whitespace cleanup
commit 07c930d4d1ff74438f15c763f94b3cff2aff353e
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Wed Jun 11 09:46:19 2014 +0000
Fixed copyright, it is GPL-3+ not GPL-2+
commit af2ff417e49d88a183bf846da0aefbf8e4dccfcc
Merge: 295b264 8f42247
commit 8cfb823f2367470cf7c1a3ae264af32b949b5f63
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Fri Sep 28 10:06:25
201
2
+0000
Date:
Wed Jun 11 09:46:00
201
4
+0000
Merge branch 'v0.0.x' of git.devlabs.linuxassist.net:awit-dbackup into v0.0.x
Fixed watch file
commit
295b264ab7b01ae796c5517ef9142f4f1bacd9e2
commit
5b6d18cce74981bd34df8a511308fbbd357836b6
Author: Nigel Kukard <nkukard@lbsd.net>
Date:
Fri Sep 28 10:03:49
201
2
+0000
Date:
Mon Jun 9 14:37:56
201
4
+0000
Bumped stable version to 0.0.19
Added VCS info to control file
commit da30c89f284149d365f2f532ec244f1e5ad12441
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Mon Jun 9 14:38:20 2014 +0000
Fixed debian dependencies
commit 2b5cd0e4aad955b7d6673d36abb1e1045f54350c
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Mon Jun 9 14:03:44 2014 +0000
This is the development branch
commit d80f67f5aaeb92e7e85bd580a32510618105309e
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Mon Jun 9 14:02:54 2014 +0000
Added watch and upstream key
commit ce6177324d61d09999b965f982824161b8d1871a
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Mon Jun 9 13:58:49 2014 +0000
Fixed up debian packaging
commit 2d3d1bf1be39c832499d6544548eb1566cca87ae
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Mon Jun 9 13:53:14 2014 +0000
Updated copyright date
commit 3f9fae37da186425dcf72321e85e80f1143af9ec
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Sun Feb 9 15:35:47 2014 +0000
Fixed whitespaces
commit 6ae1e22622150d406f49c06174a40602b2efe8cd
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Sat Oct 26 19:34:46 2013 +0000
Bumped version
commit 09b0729ac400f2b88dda613bd4459dfbeb696d33
Author: Nigel Kukard <nkukard@lbsd.net>
...
...
@@ -104,13 +210,6 @@ Date: Sun Jun 24 17:27:28 2012 +0000
Bumped version
commit 8f42247b3bcd4fbc379b909c4996b1cd1bc37cee
Merge: fbb3a45 a449d2e
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Sun Jun 24 17:26:31 2012 +0000
Merge branch 'master' into v0.0.x
commit a449d2ee978bbf44d7e32904c4d963d4434186d3
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Sun Jun 24 17:25:58 2012 +0000
...
...
@@ -119,12 +218,6 @@ Date: Sun Jun 24 17:25:58 2012 +0000
Thanks to Psi-Jack for picking it up
commit fbb3a45d327364b96f11918a93141457f1415ffb
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Thu Feb 2 20:58:03 2012 +0000
Fixed log levels in --help
commit 93f2b2e92e96f0d8f78e41e9d14335064c9b6d41
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Thu Feb 2 20:58:03 2012 +0000
...
...
@@ -323,3 +416,9 @@ Author: Nigel Kukard <nkukard@lbsd.net>
Date: Tue Jan 3 09:05:06 2012 +0000
Fixed license, this software is GPLv3 not v2
commit a195617939fc3114061eff6c91bf427f1a038765
Author: Nigel Kukard <nkukard@lbsd.net>
Date: Tue Jan 3 08:55:22 2012 +0000
Initial import
dbackup
View file @
e41b950c
...
...
@@ -41,7 +41,7 @@ use MIME::Base64;
my
$VERSION
=
"
0.0.
21
";
my
$VERSION
=
"
0.0.
x
";
# System dirs we don't care about
my
@defaultSystemExcl
=
("
/dev
","
/run
","
/proc
","
/sys
","
/tmp
","
/var/tmp
","
/misc
","
/media
","
/mnt
");
# These should be backed up separately
...
...
@@ -84,35 +84,31 @@ use constant {
};
use
constant
{
ST_FILE_CHANGED
=>
1
,
ST_DIR_NEW
=>
2
,
ST_DIR_SYS
=>
4
,
ST_DIR_CHANGED
=>
8
,
ST_FILE_ATTR_CHANGED
=>
16
,
ST_FILE_NEW
=>
32
,
ST_FILE_CHANGED
=>
1
,
ST_DIR_NEW
=>
2
,
ST_DIR_SYS
=>
4
,
ST_DIR_CHANGED
=>
8
,
ST_FILE_ATTR_CHANGED
=>
16
,
ST_FILE_NEW
=>
32
};
# Main config
my
%config
=
(
'
log-level
'
=>
LOG_NOTICE
,
'
tar
'
=>
'
tar
',
'
exclude-system
'
=>
0
,
'
backup-upgrade
'
=>
0
,
'
log-level
'
=>
LOG_NOTICE
,
'
tar
'
=>
'
tar
',
'
exclude-system
'
=>
0
,
'
backup-upgrade
'
=>
0
,
'
compress
'
=>
"
bzip2
"
);
# Choose default compression method
if
(
-
x
"
/bin/xz
"
||
-
x
"
/usr/bin/xz
"
)
{
if
(
checkPATH
("
xz
")
)
{
$config
{'
compress
'}
=
"
xz
";
}
else
{
$config
{'
compress
'}
=
"
bzip2
";
}
print
(
STDERR
"
DBackup v
$VERSION
, Copyright (c) 2010-2014, AllWorldIT
\n\n
");
print
(
STDERR
"
AWIT-DBackup v
$VERSION
, Copyright (c) 2010-2014, AllWorldIT
\n\n
");
# Grab options
...
...
@@ -160,16 +156,6 @@ if (defined($optctl{'backup'}) && defined($optctl{'restore'})) {
exit
1
;
}
# Check config file exists
if
(
!
defined
(
$optctl
{'
config
'}))
{
$optctl
{'
config
'}
=
"
/etc/dbackupc.conf
";
}
if
(
!
-
f
$optctl
{'
config
'})
{
print
(
STDERR
"
ERROR: Configuration file '
"
.
$optctl
{'
config
'}
.
"
' NOT found!
\n
");
exit
1
;
}
# Make sure we only have 2 additional args
if
(
@ARGV
>
2
||
@ARGV
<
2
)
{
print
(
STDERR
"
ERROR: Invalid number of arguments
\n\n
");
...
...
@@ -187,21 +173,33 @@ if (! -d $ARGV[1]) {
exit
1
;
}
# Use config file, ignore case
tie
my
%inifile
,
'
Config::IniFiles
',
(
-
file
=>
$optctl
{'
config
'},
-
nocase
=>
1
)
or
die
"
Failed to open config file '
"
.
$optctl
{'
config
'}
.
"
':
"
.
join
("
\n
",
@
Config::IniFiles::
errors
);
# Check if we actually have something...
if
(
defined
(
$inifile
{'
backup
'}))
{
# Loop with config items
foreach
my
$item
(
keys
%
{
$inifile
{'
backup
'}})
{
$config
{
$item
}
=
$inifile
{'
backup
'}{
$item
};
# If backup file is specified and it does not exist, throw an error
if
(
defined
(
$optctl
{'
config
'})
&&
!
-
f
$optctl
{'
config
'})
{
print
(
STDERR
"
ERROR: Configuration file '
"
.
$optctl
{'
config
'}
.
"
' NOT found!
\n
");
exit
1
;
}
# Check config file was specified, if not set default
my
$configFile
;
if
(
!
defined
(
$configFile
=
$optctl
{'
config
'}))
{
$configFile
=
"
/etc/dbackup.conf
";
}
# If we have a config file, read it in
if
(
-
f
$configFile
)
{
# Use config file, ignore case
tie
my
%inifile
,
'
Config::IniFiles
',
(
-
file
=>
$optctl
{'
config
'},
-
nocase
=>
1
)
or
die
"
Failed to open config file '
"
.
$optctl
{'
config
'}
.
"
':
"
.
join
("
\n
",
@
Config::IniFiles::
errors
);
# Check if we actually have something...
if
(
defined
(
$inifile
{'
backup
'}))
{
# Loop with config items
foreach
my
$item
(
keys
%
{
$inifile
{'
backup
'}})
{
$config
{
$item
}
=
$inifile
{'
backup
'}{
$item
};
}
}
}
#
# Process config
#
...
...
@@ -272,9 +270,10 @@ if (defined($optctl{'compress'})) {
$optctl
{'
compress
'}
ne
"
xz
"
&&
$optctl
{'
compress
'}
ne
"
bzip2
"
&&
$optctl
{'
compress
'}
ne
"
gzip
"
&&
$optctl
{'
compress
'}
ne
"
lz
"
&&
$optctl
{'
compress
'}
ne
"
none
"
)
{
print
(
STDERR
"
ERROR: Compression is invalid, valid values are: xz bzip2 gzip none
\n\n
");
print
(
STDERR
"
ERROR: Compression is invalid, valid values are: xz bzip2 gzip
lz
none
\n\n
");
displayHelp
();
exit
1
;
}
...
...
@@ -341,9 +340,9 @@ if (defined($optctl{'exclude-fs-type'})) {
if
(
@
{
$config
{'
exclude-fs-type
'}}
>
0
)
{
# Pull in mounts
open
(
MOUNTS
,
"
<
/proc/mounts
")
open
(
my
$fh
,"
<
","
/proc/mounts
")
or
die
"
ERROR: Failed to open '/proc/mounts': $!
";
while
(
my
$line
=
<
MOUNTS
>
)
{
while
(
my
$line
=
<
$fh
>
)
{
chomp
(
$line
);
# Split off items we need
my
(
undef
,
$path
,
$type
)
=
split
(
/\s+/
,
$line
);
...
...
@@ -354,9 +353,34 @@ if (@{$config{'exclude-fs-type'}} > 0) {
}
}
}
close
(
MOUNTS
);
close
(
$fh
);
}
# Look for parallel versions of the compression program we going to use
$config
{'
compress-gzip
'}
=
"
gzip
";
if
(
checkPATH
("
pigz
"))
{
$config
{'
compress-gzip
'}
=
"
pigz
";
}
$config
{'
compress-bzip2
'}
=
"
bzip2
";
if
(
checkPATH
("
pbzip2
"))
{
$config
{'
compress-bzip2
'}
=
"
pbzip2
";
}
elsif
(
checkPATH
("
lbzip2
"))
{
$config
{'
compress-lbzip2
'}
=
"
lbzip2
";
}
$config
{'
compress-xz
'}
=
"
xz
";
if
(
checkPATH
("
pxz
"))
{
$config
{'
compress-xz
'}
=
"
pxz
";
}
elsif
(
checkPATH
("
pixz
"))
{
$config
{'
compress-xz
'}
=
"
pixz
";
}
$config
{'
compress-lz
'}
=
"
clzip
";
if
(
checkPATH
("
plzip
"))
{
$config
{'
compress-lz
'}
=
"
plzip
";
}
elsif
(
checkPATH
("
pdlzip
"))
{
$config
{'
compress-lz
'}
=
"
pdlzip
";
}
# Sanitize the source and dest
my
$sourceDir
=
File::
Spec
->
rel2abs
(
$ARGV
[
0
]);
my
$destDir
=
File::
Spec
->
rel2abs
(
$ARGV
[
1
]);
...
...
@@ -785,14 +809,17 @@ sub backup
my
@tarArgs
=
();
my
$tarExt
;
if
(
$config
{'
compress
'}
eq
"
xz
")
{
push
(
@tarArgs
,"
--
xz
"
);
push
(
@tarArgs
,"
--
use-compress-program
",
$config
{'
compress-xz
'}
);
$tarExt
=
"
.xz
";
}
elsif
(
$config
{'
compress
'}
eq
"
bzip2
")
{
push
(
@tarArgs
,"
--bzip2
"
);
push
(
@tarArgs
,"
--
use-compress-program
",
$config
{'
compress-
bzip2
'}
);
$tarExt
=
"
.bz2
";
}
elsif
(
$config
{'
compress
'}
eq
"
gzip
")
{
push
(
@tarArgs
,"
--gzip
"
);
push
(
@tarArgs
,"
--
use-compress-program
",
$config
{'
compress-
gzip
'}
);
$tarExt
=
"
.gz
";
}
elsif
(
$config
{'
compress
'}
eq
"
lz
")
{
push
(
@tarArgs
,"
--use-compress-program
",
$config
{'
compress-lz
'});
$tarExt
=
"
.lz
";
}
elsif
(
$config
{'
compress
'}
eq
"
none
")
{
$tarExt
=
"";
}
...
...
@@ -835,7 +862,7 @@ sub backup
}
# File list to backup
open
(
MANIFEST
,"
>
$dest
/
$path
/dbackup
$seq
.manifest
")
open
(
my
$fh
,"
>
","
$dest
/
$path
/dbackup
$seq
.manifest
")
or
die
"
Failed to open '[
$dest
]/(
$path
)/dbackup
$seq
.manifest': $!
";
foreach
my
$item
(
@manifestList
)
{
# Sanity check to see if this filename is going to work
...
...
@@ -845,13 +872,13 @@ sub backup
}
# If this is not the top dir, use /
if
(
$path
ne
"")
{
print
(
MANIFEST
"
$path
/
$item$manifestDelim
");
print
(
$fh
"
$path
/
$item$manifestDelim
");
# If it is, don't use /
}
else
{
print
(
MANIFEST
"
$item$manifestDelim
");
print
(
$fh
"
$item$manifestDelim
");
}
}
close
(
MANIFEST
);
close
(
$fh
);
# tar specifics...
if
(
$newPathAttribs
{
$path
}
->
{'
format
'}
eq
"
tar
")
{
...
...
@@ -897,8 +924,7 @@ sub backup
# exit 1;
}
}
# if (($doBackup{$path} & ST_DIR_SYS) != ST_DIR_SYS) {
}
else
{
}
else
{
# if (($doBackup{$path} & ST_DIR_SYS) != ST_DIR_SYS) {
# Remove old files
removeBackups
(
"
$dest
/
$path
",
...
...
@@ -984,7 +1010,7 @@ sub backup
}
printLog
(
LOG_NOTICE
,"
BACKUP START:
$source
=>
$dest
\n
");
printLog
(
LOG_INFO
,"
Compression:
"
.
$config
{'
compress
'}
.
"
\n
");
printLog
(
LOG_INFO
,"
Compression:
"
.
$config
{'
compress
'}
.
"
[
"
.
$config
{'
compress-
'
.
$config
{'
compress
'}}
.
"
]
\n
");
# Check if we excluding system files
if
(
$config
{'
exclude-system
'})
{
...
...
@@ -1039,10 +1065,20 @@ sub backup
}
# Do backup
# If we backing up or restoring, we need to check the compression program
if
(
defined
(
$optctl
{'
backup
'})
||
defined
(
$optctl
{'
restore
'}))
{
# One last check for to make sure the compression program exists
if
(
checkPATH
(
my
$compressProgram
=
"
compress-
"
.
$config
{'
compress
'}))
{
print
(
STDERR
"
ERROR: Compression program '
$compressProgram
' cannot be found in path!
");
exit
1
;
}
}
# Check if we backing up
if
(
defined
(
$optctl
{'
backup
'}))
{
backup
(
$sourceDir
,
$destDir
);
# Or restoring...
}
elsif
(
defined
(
$optctl
{'
restore
'}))
{
restore
(
$sourceDir
,
$destDir
);
...
...
@@ -1053,15 +1089,13 @@ if (defined($optctl{'backup'})) {
}
# Restore function
sub
restore
{
our
(
$source
,
$dest
)
=
@_
;
# State infor for current dir
# our %doBackup;
# our %srcFileList;
# our %srcDirList;
our
%origFileList
;
our
%origDirList
;
our
%origPathAttribs
;
...
...
@@ -1113,14 +1147,17 @@ sub restore
my
$tarExt
;
if
(
$origPathAttribs
{
$path
}
->
{'
compression
'}
eq
"
xz
")
{
push
(
@tarArgs
,"
--
xz
"
);
push
(
@tarArgs
,"
--
use-compress-program
",
$config
{'
compress-xz
'}
);
$tarExt
=
"
.xz
";
}
elsif
(
$origPathAttribs
{
$path
}
->
{'
compression
'}
eq
"
bzip2
")
{
push
(
@tarArgs
,"
--bzip2
"
);
push
(
@tarArgs
,"
--
use-compress-program
",
$config
{'
compress-
bzip2
'}
);
$tarExt
=
"
.bz2
";
}
elsif
(
$origPathAttribs
{
$path
}
->
{'
compression
'}
eq
"
gzip
")
{
push
(
@tarArgs
,"
--gzip
"
);
push
(
@tarArgs
,"
--
use-compress-program
",
$config
{'
compress-
gzip
'}
);
$tarExt
=
"
.gz
";
}
elsif
(
$origPathAttribs
{
$path
}
->
{'
compression
'}
eq
"
lz
")
{
push
(
@tarArgs
,"
--use-compress-program
",
$config
{'
compress-lz
'});
$tarExt
=
"
.lz
";
}
elsif
(
$origPathAttribs
{
$path
}
->
{'
compression
'}
eq
"
none
")
{
$tarExt
=
"";
}
...
...
@@ -1357,7 +1394,7 @@ Usage: $0 [args] <src> <dst>
Backing
Options:
--
backup
Backup
src
to
dst
.
--
backup
-
upgrade
Upgrade
backup
to
new
dbackup
ver
.
--
compress
=<
xz
|
bz2
|
gzip
|
none
>
Compression
method
to
use
defaults
--
compress
=<
xz
|
bz2
|
gzip
|
lz
|
none
>
Compression
method
to
use
defaults
to
using
xz
,
or
bzip2
if
xz
unavail
.
--
exclude
-
data
Exclude
all
data
dirs
listed
below
.
...
...
@@ -1454,6 +1491,7 @@ sub loadStateFile {
}
# Remove backup and its sequences
sub removeBackups
{
my ($path,$format,$compression,$seqs) = @_;
...
...
@@ -1469,6 +1507,8 @@ sub removeBackups
$tarExt = ".bz2";
} elsif ($compression eq "gzip") {
$tarExt = ".gz";
} elsif ($compression eq "lz") {
$tarExt = ".lz";
} elsif ($compression eq "none") {
$tarExt = "";
}
...
...
@@ -1497,6 +1537,8 @@ sub removeBackups
}
}
# Convert a possible string to an array, or return the array if it is indeed an array
sub toArray
{
my $param = shift;
...
...
@@ -1508,23 +1550,29 @@ sub toArray
}
}
# Grab tar version
sub getTarVer
{
my $tar = shift;
open(TAR, $config{
'
tar
'
} . " --version |")
# Open tar and grab its version string
open(my $ph, "-|", $config{
'
tar
'
} . " --version")
or die "FAILED to execute
'"
.
$config
{'tar'}.
"'
: $!";
if (!($tarVer = <
TAR
>)) {
if (!($tarVer = <
$ph
>)) {
print(STDERR "ERROR: Failed to read tar version\n");
exit 1;
}
close($ph);
# Convert version string into integer and return it
($tarVer) = ($tarVer =~ /([0-9]+\.[0-9]+)/);
if (!defined($tarVer) || $tarVer eq "") {
print(STDERR "ERROR: Failed to parse tar version\n");
exit 1;
}
$tarVer =~ s/\.//g;
close(TAR);
if ($tarVer < 100) {
print(STDERR "ERROR: Failed to read tar version or your version is simply too old\n");
exit 1;
...
...
@@ -1533,6 +1581,8 @@ sub getTarVer
return $tarVer;
}
# Convert a triplet version into an integer
sub getNumericVer
{
my $a = shift;
...
...
@@ -1547,4 +1597,22 @@ sub getNumericVer
return ( ($a[0]*1000000) + ($a[1]*1000) + $a[2] );
}
# Function to check if a binary is in our PATH
sub checkPATH
{
my $binary = shift;
# Loop with PATH components
for my $path (split(/:/,$ENV{PATH})) {
# And check if the binary is executable
if (-x "$path/$binary") {
return 1;
}
}
return 0;
}
# vim: ts=4
debian/awit-dbackup.install
View file @
e41b950c
# Main script
dbackup
usr
/
sbin
# Config
...
...
debian/awit-dbackup.manpages
View file @
e41b950c
debian/dbackup.
1
debian/dbackup.
8
debian/changelog
View file @
e41b950c
awit-dbackup (0.0.2
1
-1-1) stable; urgency=low
* Updated to upstream
v
0.0.2
1
-1
-- Nigel Kukard <nkukard@lbsd.net>
Mon, 09 Jun 2014 16:08:23
+0200
awit-dbackup (0.0.2
2
-1-1) stable; urgency=low
* Updated to upstream 0.0.2
2
-1
-- Nigel Kukard <nkukard@lbsd.net>
Thu, 11 Sep 2014 18:30:15
+0200
debian/clean
0 → 100644
View file @
e41b950c
debian/dbackup.8
debian/control
View file @
e41b950c
...
...
@@ -5,12 +5,15 @@ Priority: optional
Standards-Version: 3.9.5
Build-Depends: debhelper (>= 9), docbook-to-man