-
Notifications
You must be signed in to change notification settings - Fork 1
/
brackup-mount
executable file
·128 lines (90 loc) · 3.92 KB
/
brackup-mount
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/perl
# LICENCE INFORMATION
#
# This file is part of brackup-nn, a backup tool based on Brackup.
#
# Brackup is authored by Brad Fitzpatrick <[email protected]> (and others)
# and is copyright (c) Six Apart, Ltd, with portions copyright (c) Gavin Carr
# <[email protected]> (see code for details). Brackup is licensed for
# use, modification and/or distribution under the same terms as Perl itself.
#
# This file was forked from Brackup on 18 March 2013 and changed on and since
# this date by NewsNow Publishing Limited to effect bug fixes, reliability
# stability and/or performance improvements, and/or feature enhancements;
# and such changes are copyright (c) 2013 NewsNow Publishing Limited. You may
# use, modify, and/or redistribute brackup-nn under the same terms as Perl itself.
#
use strict;
=head1 NAME
brackup-mount - mount a backup as a filesystem using FUSE
=cut
# Make a friendly error message if Fuse isn't installed
BEGIN {
eval { require Fuse; };
if ($@) {
print STDERR "brackup-mount requires the 'Fuse' library from CPAN\n";
exit(1);
}
}
use Brackup::Mount;
my $metafile = shift or usage('No metafile specified');
my $mountpoint = shift or usage('No mountpoint specified');
Brackup::Mount->mount($metafile, $mountpoint);
sub usage {
my $why = shift || "";
if ($why) {
$why =~ s/\s+$//;
$why = "Error: $why\n\n";
}
print STDERR "${why}brackup-mount <metafile> <mountpoint>\n";
exit(1);
}
=head1 SYNOPSIS
brackup-mount <metafile> <mountpoint>
=head1 DESCRIPTION
C<brackup-mount> allows you to mount a backup into your filesystem
at a particular mount point. Once it's mounted, you'll have a
read-only view of the directories and files in the backup
at the mountpoint given.
For example:
brackup-mount somebackup-20080203.brackup /mnt
This might be useful if you need to refer to something from a backup
but you don't want to do a full restore. You can also, if you like, do
something resembling a restore by mounting a backup and copying the
contents into your "real" filesystem.
=head1 PREREQUISITES
Before using this utility, you'll need to install the C<Fuse> library
from CPAN:
perl -MCPAN -e "install Fuse"
If you're on a Debian-like system then this might be a better idea:
apt-get install libfuse-perl
=head1 WARNING
This program is EXPERIMENTAL. Do not use it for anything important.
=head1 HOW IT WORKS
C<brackup-mount> reads the metafile it is given and uses the metadata
within to create a filesystem that is exposed via FUSE. All operations
apart from reading from files operate purely on the in-memory data structure
created from the metafile, and so you can C<ls> and C<stat> files to
your heart's content without worrying about expensive calls to your
target.
When a process calls C<open> on a file, the file will be effectively
"restored" from the backup target into a temporary directory, where it
will remain until it is ultimately C<close>d. All C<read> operations
on the file are performed on the temporary file. This means that you
can expect the C<open> call to be the most expensive call against this
filesystem.
If you're paying for data transfer from your target, be aware that
the local copy retrieved on C<open> is thrown away on C<close>, so if you
plan to be opening and closing the same file repeatedly you might
want to force the local copy to be retained for the duration by running
something like C<tail -f filename> in another terminal.
Since Brackup does not retain information about file ownership, all
files in the mounted filesystem will be owned by the user that mounted
the filesystem. The permissions from the brackup metafile are
returned to C<stat> (so you can do C<cp -P>), but aren't enforced on C<open>.
=head1 AUTHOR
Martin Atkins <[email protected]>
=head1 LICENCE
This program and its associated library are part of the Brackup distribution
and can be disstributed under the same terms as Brackup itself.
=cut