|
From: <fcr...@us...> - 2013-01-01 08:03:13
|
Revision: 834
http://safekeep.svn.sourceforge.net/safekeep/?rev=834&view=rev
Author: fcrawford
Date: 2013-01-01 08:03:06 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
- Allow default snapshot size to be set in safekeep.conf.
- Enable all lvcreate(8) size options, including %age to be given.
Modified Paths:
--------------
safekeep/trunk/TODO
safekeep/trunk/doc/safekeep.backup.txt
safekeep/trunk/doc/safekeep.conf.txt
safekeep/trunk/safekeep
safekeep/trunk/safekeep.conf
Modified: safekeep/trunk/TODO
===================================================================
--- safekeep/trunk/TODO 2013-01-01 07:04:07 UTC (rev 833)
+++ safekeep/trunk/TODO 2013-01-01 08:03:06 UTC (rev 834)
@@ -16,7 +16,7 @@
Future (post 1.0):
* Modify the test to not rely on Lattica's servers
- * Decide how big the snapshot size should be automagically
+ * Decide how big the snapshot size should be automagically (Partially DONE)
* Fully automatic shapshotting mode
* Configuration inheritance
* Transactional ops on server side, and automagic recovery from errors (Partially DONE)
Modified: safekeep/trunk/doc/safekeep.backup.txt
===================================================================
--- safekeep/trunk/doc/safekeep.backup.txt 2013-01-01 07:04:07 UTC (rev 833)
+++ safekeep/trunk/doc/safekeep.backup.txt 2013-01-01 08:03:06 UTC (rev 834)
@@ -255,12 +255,16 @@
/backup/setup/snapshot/@size::
The size of the snapshot. Unallocated space must exist on
the volume group. It is recommended that it is about 15-20%
- of the original device's size.
- Mandatory for a `<snapshot>` element.
+ of the original device's size. This can be specified as a
+ percentage, e.g. `20%`, which is equivalent to 20% of the
+ logical volume. Other values as listed for `lvcreate(8)`
+ can also be given.
+ Mandatory for a `<snapshot>` element, unless a default value
+ has been specified in `safekeep.conf`.
/backup/setup/snapshot/@tag::
A list of tags to be added to the snapshot, with the `--addtag`
- argument to `lvcreate`. The @tag entry consists of a `,`
+ argument to `lvcreate(8)`. The @tag entry consists of a `,`
separated list of tags.
An `@` is automatically added to each generated tag.
Optional for a `<snapshot>` element.
Modified: safekeep/trunk/doc/safekeep.conf.txt
===================================================================
--- safekeep/trunk/doc/safekeep.conf.txt 2013-01-01 07:04:07 UTC (rev 833)
+++ safekeep/trunk/doc/safekeep.conf.txt 2013-01-01 08:03:06 UTC (rev 834)
@@ -121,6 +121,15 @@
the value set in `bandwidth.overall` (refer to it for more
informatio). This value is optional.
+snapshot.size::
+ This is the default size to be used for any snapshots without a
+ `size` value specified.
+ It is passed to 'lvcreate(8)' (LVM2), including the specification of
+ a percentage (`%`). If not otherwise specified, the percentage is
+ based on unallocated space (i.e. LVM2 `%FREE'), which is different
+ to the interpretation within the `<snapshot>` option.
+ This value is optional and there is no default.
+
NOTES
-----
Safekeep uses `trickle` to implement bandwidth throttling (see
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2013-01-01 07:04:07 UTC (rev 833)
+++ safekeep/trunk/safekeep 2013-01-01 08:03:06 UTC (rev 834)
@@ -70,6 +70,7 @@
client_defaults = []
current_pid = os.getpid()
default_bandwidth = {}
+default_snapshot = None
statistics = []
# Default mount options, overridden elsewhere:
# Key is a file system type, or 'snapshot' for default for snapshot mount
@@ -461,12 +462,13 @@
'opts' : opts, 'file' : dbfile, 'cleanup' : cleanup }
def parse_snap(snap_el):
+ global default_snapshot
device = snap_el.getAttribute('device')
if not device:
raise ConfigException('Please specify the device to be snapshot')
if device.rfind('/') == -1 or device.endswith('/'):
raise ConfigException('The device name seems incorrect: ' + device)
- size = snap_el.getAttribute('size')
+ size = snap_el.getAttribute('size') or default_snapshot
if not size:
raise ConfigException('Please specify the size for the snapshot')
tags = []
@@ -858,8 +860,13 @@
if snap['tags']:
for tag in snap['tags']:
args.extend(['--addtag', tag.strip()])
- args.extend(['--snapshot', '--size', snap['size'],
- '--name', os.path.basename(snapdev), lvmdev])
+ size = snap['size']
+ if size.count('%'):
+ if size.endswith('%'): size += 'ORIGIN'
+ args.extend(['--snapshot', '--extents', size])
+ else:
+ args.extend(['--snapshot', '--size', size])
+ args.extend(['--name', os.path.basename(snapdev), lvmdev])
ec = spawn(args)
if ec:
warn('Can not snapshot the device: %s' % device)
@@ -1979,6 +1986,13 @@
default_bandwidth['download'] = get_int('bandwidth.limit.download') or 0
default_bandwidth['upload'] = get_int('bandwidth.limit.upload') or 0
+ global default_snapshot, client_defaults
+ default_snapshot = props.get('snapshot.size')
+ if default_snapshot:
+ if default_snapshot.endswith('%'):
+ default_snapshot += 'FREE'
+ client_defaults.append('snapshot.size=%s' % default_snapshot)
+
if len(cfglocs) == 0:
locs = os.path.join(os.path.dirname(cfgfile), 'backup.d')
if os.path.isdir(locs): cfglocs.append(locs)
Modified: safekeep/trunk/safekeep.conf
===================================================================
--- safekeep/trunk/safekeep.conf 2013-01-01 07:04:07 UTC (rev 833)
+++ safekeep/trunk/safekeep.conf 2013-01-01 08:03:06 UTC (rev 834)
@@ -49,3 +49,7 @@
# Generate a summary with the email message
# email.summary = yes|no
+# Default size for LVM snapshots
+# This follows the rules for lvcreate(8), so can be a fixed size or
+# a % of either logical volume or free space.
+# snapshot.size = 2G
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|