Heyho! Please consider the attached patch. (against 1.2.1)
Storing the dirvish trees in btrfs snapshots instead of using rsync's --
link-deest option makes sense, IMO, because:
* vastly accelerated dirvish-expire ("btrfs subvol delete" is a constant
time operation independently of how big the tree is)
* uses less disk space (and, but I didn't benchmark this, potentially
should be faster) because a copy on write snapshot is smaller and can be
created in O(1) time compared with a hardlinked directory tree.
* protection from accidental modification of a file in a tree (stupid, but
it happens ...)
* using rsync --inplace: takes advantage of btrfs' copy on write for files
that have modified portions and portions that have stayed the same.
Long term: content deduplication for btrfs filesystems probably will be
written sooner or later, when space savings through btrfs' copy on write
pages for backups of multiple similar trees will become even more
interesting.
I've written it basically for the first two reasons and because I really
like the possibilities offered by btrfs...
cheers
-- vbi
--
How to overclock the board to the attachment from Windows?
You should telnet from the floppy disk and from the tools menu inside
Netscape you either never have to log from the POP3 miditower, or can't
debug a clock of a OpenGL file of a software of a BIOS in order to
explore the editor.
diff --git a/dirvish-expire.pl b/dirvish-expire.pl
--- a/dirvish-expire.pl
+++ b/dirvish-expire.pl
@@ -166,7 +166,12 @@
$$Options{'no-run'} and next;
- system("rm -rf $$expire{path}/tree");
+ if ($$Options{btrfs})
+ {
+ system("btrfs subvolume delete $$expire{path}/tree > /dev/null");
+ } else {
+ system("rm -rf $$expire{path}/tree");
+ }
$$Options{tree} and next;
system("rm -rf $$expire{path}");
diff --git a/dirvish.conf.5 b/dirvish.conf.5
--- a/dirvish.conf.5
+++ b/dirvish.conf.5
@@ -177,6 +177,9 @@
.Bi branch\-default: branch_name (S)
Specify a default \*[branch] to use.
.TP
+.Bi btrfs: (B)
+If true, use btrfs snapshots instead of hardlinked trees.
+.TP
.Bi client: \*ousern...@\*cclient_name (S)
specify a client to back up.
diff --git a/dirvish.pl b/dirvish.pl
--- a/dirvish.pl
+++ b/dirvish.pl
@@ -93,6 +93,7 @@
whole-file
xdev
zxfer
+ btrfs
);
%RSYNC_OPT = ( # simple options
@@ -449,11 +450,29 @@
scalar @{$$Options{exclude}}
and push @rsyncargs, '--exclude-from=' . $exl_file;
+# take full advantage of btrfs copy on write
+$$Options{btrfs}
+ and push @rsyncargs, '--inplace';
+
if (!$$Options{'no-run'})
{
mkdir "$vault/$image", 0700
or seppuku 230, "mkdir $vault/$image failed";
- mkdir $destree, 0755;
+ # tree/ is a btrfs subvolume instead of a normal directory
+ if ($$Options{btrfs})
+ {
+ if ($$Options{init})
+ {
+ system("btrfs subvolume create $destree > /dev/null") == 0
+ or seppuku 233, "creating btrfs volume at $vault/$image/tree failed";
+ } else {
+ system("btrfs subvolume snapshot $reftree $destree > /dev/null") == 0
+ or seppuku 234, "creating btrfs snapshot at $vault/$image/tree failed";
+ }
+ } else {
+ mkdir $destree, 0755;
+ }
+
open(SUMMARY, ">$vault/$image/summary")
or seppuku 231, "cannot create $vault/$image/summary";
@@ -509,7 +528,7 @@
printf SUMMARY "%s: %s\n", $key, $val;
}
-$$Options{init} or push @rsyncargs, "--link-dest=$reftree";
+$$Options{init} or $$Options{btrfs} or push @rsyncargs, "--link-dest=$reftree";
$rclient = undef;
$$Options{client} ne $$Options{Server}
@@ -757,7 +776,12 @@
if($status{fatal})
{
- system ("rm -rf $destree");
+ if ($$Options{btrfs})
+ {
+ system ("btrfs subvolume delete $destree > /dev/null");
+ } else {
+ system ("rm -rf $destree");
+ }
unlink $err_temp;
printf SUMMARY "%s: %s\n", 'Status', $Status_msg;
exit 199;
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Dirvish mailing list [email protected] http://www.dirvish.org/mailman/listinfo/dirvish
