|
From: <di...@us...> - 2009-03-16 15:05:28
|
Revision: 637
http://safekeep.svn.sourceforge.net/safekeep/?rev=637&view=rev
Author: dimi
Date: 2009-03-16 15:05:14 +0000 (Mon, 16 Mar 2009)
Log Message:
-----------
Frank Crawford <fr...@cr...>
Rework the handling of device files, fifos and sockets as data attributes.
Now special files are by default included, unless explicitely excluded.
A bunch of spelling fixes sprinkled throughout.
Modified Paths:
--------------
safekeep/trunk/doc/safekeep.backup.txt
safekeep/trunk/safekeep
safekeep/trunk/samples/sample.backup
Modified: safekeep/trunk/doc/safekeep.backup.txt
===================================================================
--- safekeep/trunk/doc/safekeep.backup.txt 2009-03-15 14:52:52 UTC (rev 636)
+++ safekeep/trunk/doc/safekeep.backup.txt 2009-03-16 15:05:14 UTC (rev 637)
@@ -38,16 +38,12 @@
and for how long (D=days, W=weeks, M=months, or Y=years) -->
<repo path="./data" retention="10D"/>
- <options>
- <special-files include="false" />
- </options>
-
<!-- settings for database dump and for volume snapshot -->
<setup>
<!-- database type ("postgres" or "mysql"), and database name,
DB user with backup rights, location of the dump file on the client
host, and flag to remove or not the dump file after the backup is done.
- Databases can be dumped individualy using a dump clause for each database. -->
+ Databases can be dumped individually using a dump clause for each database. -->
<dump
type="postgres"
db="my_db"
@@ -74,7 +70,7 @@
</setup>
<!-- data to be backup -->
- <data>
+ <data exclude-fifos="true" exclude-sockets="true">
<!-- each type of tag can be present more than one time -->
<!-- if a database dump was created, it must be added in this section -->
<include path="/home"/>
@@ -156,7 +152,7 @@
will fail altogether if the directory can not be created.
Optional, defaults to the client ID, see `/backup/@id`.
Use of the default value is *highly* recommended.
- *NOTE*: if you must set this value explicitely, you must
+ *NOTE*: if you must set this value explicitly, you must
make sure that the path is not shared between different boxes;
a shared repository path _will_ result in data loss.
@@ -179,11 +175,12 @@
Optional, defaults to empty (unlimited retention).
/backup/options/special-files/@include::
+ NOTE: THIS OPTION HAS BEEN DEPRECATED. See data attributes below.
One of "true" or "false". If "true", the dump file will
include all special files, including device files, fifo files and
socket files.
Optional, defaults to "false".
- *NOTE*: specification of no options is equalent to false, but the
+ *NOTE*: specification of no options is equivalent to false, but the
inclusion of other options may cause the underlying backup defaults
to be use.
@@ -267,6 +264,30 @@
See the `CLIENT SCRIPT` section for more information.
Mandatory for a `<script>` element.
+/backup/data/@exclude-devices::
+ One of "true" or "false". If "true", the dump file will
+ exclude all device files.
+ Optional, defaults to "false".
+ *NOTE*: specification of no attributes is equivalent to false, but the
+ inclusion of other options may cause the underlying backup defaults
+ to be use.
+
+/backup/data/@exclude-fifos::
+ One of "true" or "false". If "true", the dump file will
+ exclude all fifos.
+ Optional, defaults to "false".
+ *NOTE*: specification of no attributes is equivalent to false, but the
+ inclusion of other options may cause the underlying backup defaults
+ to be use.
+
+/backup/data/@exclude-sockets::
+ One of "true" or "false". If "true", the dump file will
+ exclude all sockets.
+ Optional, defaults to "false".
+ *NOTE*: specification of no attribute is equivalent to false, but the
+ inclusion of other options may cause the underlying backup defaults
+ to be use.
+
/backup/data/exclude/@path::
Exclude the file or files matched by the path.
If a directory is matched, then files under that directory will also
@@ -314,7 +335,7 @@
Each file selection condition either matches or doesn't match a given file.
A given file is included or excluded by the file selection system when the
first matching file selection condition specifies that the file be included
-or excluded respecively; if the file matches no include or exclude
+or excluded respectively; if the file matches no include or exclude
statement, it is by default excluded.
When backing up, if a file is excluded, `safekeep(1)` acts
@@ -340,7 +361,7 @@
The steps currently defined and tokens passed, are:
- STARTUP - prior to any execution, however, if it exits with a non-zero
-status this constitues an error and the backup is aborted.
+status this constitutes an error and the backup is aborted.
- PRE-SETUP - prior to running any setup steps being run. A non-zero status
is considered a warning and execution continues.
- POST-SETUP - after setup, but prior to execution of backup. A non-zero
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2009-03-15 14:52:52 UTC (rev 636)
+++ safekeep/trunk/safekeep 2009-03-16 15:05:14 UTC (rev 637)
@@ -263,6 +263,13 @@
'upload': int(bw_el.getAttribute('upload') or 0)
}
+def parse_data_attributes(data_el):
+ return {
+ 'exclude-devices': (data_el.getAttribute('exclude-devices') or 'false'),
+ 'exclude-sockets': (data_el.getAttribute('exclude-sockets') or 'false'),
+ 'exclude-fifos': (data_el.getAttribute('exclude-fifos') or 'false')
+ }
+
def parse_config(backup_el, dflt_id):
if backup_el.tagName != 'backup':
raise ConfigException('Invalid config file, the top level element must be <backup>')
@@ -293,7 +300,7 @@
if len(bw_el) == 1:
bw = parse_bandwidth(bw_el[0])
elif len(bw_el) > 1:
- raise ConfigException('Can not have more than a bandwidth element')
+ raise ConfigException('Can not have more than one bandwidth element')
repo_el = backup_el.getElementsByTagName('repo')
dir = None
@@ -302,7 +309,7 @@
dir = repo_el[0].getAttribute('path')
retention = repo_el[0].getAttribute('retention')
elif len(repo_el) > 1:
- raise ConfigException('Can not have more than a repo element')
+ raise ConfigException('Can not have more than one repo element')
if not dir: dir = id
dir = os.path.join(base_dir, dir)
@@ -313,6 +320,8 @@
if options_el.nodeType != options_el.ELEMENT_NODE:
continue
option = options_el.nodeName
+ if option == 'special-files':
+ warn('options element special-files is deprecated, use data attributes instead')
if option in ('special-files', 'rdiff-backup'):
if options_el.hasAttributes():
for key, value in options_el.attributes.items():
@@ -339,9 +348,11 @@
elif len(script_el) > 1:
raise ConfigException('Can not have more than one setup script element')
+ data_options = {}
data_el = backup_el.getElementsByTagName('data')
- if data_el:
+ if len(data_el) == 1:
+ data_options = parse_data_attributes(data_el[0])
child_els = data_el[0].childNodes
cludes = []
for child_el in child_els:
@@ -351,6 +362,8 @@
continue
cludes.append(parse_clude(child_el))
cludes.append({ 'type' : 'exclude', 'path' : '', 'glob' : '', 'regexp' : '.*' })
+ elif len(data_el) > 1:
+ raise ConfigException('Can not have more than one data element')
else:
path_xcludes = [ '/dev/', '/media/', '/mnt/', '/net/', '/proc/', '/selinux/', '/sys/',
'/tmp/', '/var/cache', '/var/lock', '/var/run', '/var/tmp',
@@ -360,7 +373,7 @@
return { 'id': id, 'host' : host, 'user' : user, 'key_ctrl' : key_ctrl, 'key_data' : key_data,
'dir' : dir, 'retention' : retention, 'dumps' : dumps, 'snaps' : snaps, 'script' : script,
- 'cludes' : cludes, 'options' : options, 'bw': bw}
+ 'cludes' : cludes, 'data_options' : data_options, 'options' : options, 'bw' : bw}
def parse_locs(cfglocs):
cfgfiles = []
@@ -497,7 +510,7 @@
def do_client_dbdump_teardown(cfg):
debug('Tear down DB dumps')
for dump in cfg['dumps']:
- if dump['cleanup'] != 'true':
+ if dump['cleanup'].lower() != 'true':
continue
try:
os.remove(dump['file'])
@@ -844,7 +857,15 @@
args.extend(['--force'])
options_append = []
- special_files = ['--exclude-device-files', '--exclude-sockets', '--exclude-fifos']
+
+ special_files = []
+ if cfg['data_options'].get('exclude-devices').lower() == 'true':
+ special_files.extend(['--exclude-device-files'])
+ if cfg['data_options'].get('exclude-sockets').lower() == 'true':
+ special_files.extend(['--exclude-sockets'])
+ if cfg['data_options'].get('exclude-fifos').lower() == 'true':
+ special_files.extend(['--exclude-fifos'])
+
for option in cfg['options']:
if 'special-files' in option:
if 'include' in option['special-files']:
Modified: safekeep/trunk/samples/sample.backup
===================================================================
--- safekeep/trunk/samples/sample.backup 2009-03-15 14:52:52 UTC (rev 636)
+++ safekeep/trunk/samples/sample.backup 2009-03-16 15:05:14 UTC (rev 637)
@@ -9,7 +9,7 @@
key-data="/home/jdoe/.ssh/backup2_id_dsa"
/>
- <!-- location where the backuped data will be stored on the server
+ <!-- location where the backed up data will be stored on the server
and for how long (s=sec, m=min, h=hours, D=days, W=weeks, M=months, or Y=years) -->
<repo
path="./data"
@@ -45,8 +45,8 @@
/>
</setup>
- <!-- data to be backuped -->
- <data>
+ <!-- data to be backed up -->
+ <data exclude-fifos="true" exclude-sockets="true">
<!-- each type of tag can be present more than one time -->
<!-- if a database dump was created, it must be added in this section -->
<include path="/home"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|