Skip to content

Commit 20359a9

Browse files
committed
issue rear#171
adding sshfs support to rear - tested mkbackup/recover successfully
1 parent bdeb13e commit 20359a9

File tree

6 files changed

+62
-19
lines changed

6 files changed

+62
-19
lines changed

doc/rear.8

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
'\" t
22
.\" Title: rear
33
.\" Author: [see the "AUTHORS" section]
4-
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
5-
.\" Date: 7 Jun 2011
6-
.\" Manual: \ \&
7-
.\" Source: \ \&
4+
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
5+
.\" Date: 09/27/2012
6+
.\" Manual: [FIXME: manual]
7+
.\" Source: [FIXME: source]
88
.\" Language: English
99
.\"
10-
.TH "REAR" "8" "7 Jun 2011" "\ \&" "\ \&"
10+
.TH "REAR" "8" "09/27/2012" "[FIXME: source]" "[FIXME: manual]"
11+
.\" -----------------------------------------------------------------
12+
.\" * Define some portability stuff
13+
.\" -----------------------------------------------------------------
14+
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15+
.\" http://bugs.debian.org/507673
16+
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17+
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18+
.ie \n(.g .ds Aq \(aq
19+
.el .ds Aq '
1120
.\" -----------------------------------------------------------------
1221
.\" * set default formatting
1322
.\" -----------------------------------------------------------------

doc/rear.8.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= rear(8)
2-
:version: v1.12.0
3-
:date: 7 Jun 2011
2+
:version: v1.14.0
3+
:date: 14 Nov 2012
44
:data-uri:
55
:doctype: manpage
66
:lang: en
@@ -187,6 +187,8 @@ Write the image using +lftp+ and the secure FTP (SFTP) protocol.
187187
OUTPUT_URL=*rsync://*::
188188
Write the image using +rsync+ and the RSYNC protocol.
189189

190+
OUTPUT_URL=*sshfs://*::
191+
Write the image using sshfs and the SSH protocol.
190192

191193
== BACKUP SOFTWARE INTEGRATION
192194
Currently Relax-and-Recover supports the following backup methods. Please
@@ -267,13 +269,19 @@ domain=_domain_
267269
----
268270

269271
BACKUP_URL=*usb://*::
270-
To backup to USB storage device, use +NETFS=usb:///dev/disk/by-path/REAR-000+
272+
To backup to USB storage device, use +BACKUP_URL=usb:///dev/disk/by-path/REAR-000+
271273
or use a real device node or a specific filesystem label. Alternatively, you
272274
can specify the device using +USB_DEVICE=/dev/disk/by-path/REAR-000+.
273275
+
274276
If you combine this with +OUTPUT=USB+ you will end up with a bootable USB
275277
device.
276278

279+
BACKUP_URL=*sshfs://*::
280+
To backup to a remote server via sshfs (SSH protocol), use
281+
+BACKUP_URL=sshfs://[email protected]/home/user/backup-dir/+
282+
+
283+
It is advisable to add *ServerAliveInterval 15* in the +/root/.ssh/config+
284+
file for the remote system (remote-system.domain.org).
277285

278286
== CONFIGURATION
279287
To configure Relax-and-Recover you have to edit the configuration files in
@@ -340,7 +348,7 @@ for the given release and platform.
340348
To create a new rescue environment. Do not forget to copy the resulting
341349
rescue system away so that you can use it in the case of a system failure.
342350

343-
# rear mkrescue
351+
# rear -v mkrescue
344352

345353

346354
== FILES
@@ -351,7 +359,7 @@ The program itself.
351359
System specific configuration can be set here.
352360

353361
/etc/rear/site.conf::
354-
Site specific configuration can be set here.
362+
Site specific configuration can be set here (not created by default).
355363

356364
/var/log/rear/::
357365
Directory holding the log files.

usr/share/rear/conf/GNU/Linux.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tee
2525
awk
2626
ip
2727
ifconfig
28+
nslookup
2829
route
2930
ifenslave
3031
ifrename

usr/share/rear/lib/global-functions.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ mount_url() {
9393
(usb)
9494
mount_cmd="mount $v -o $options $(url_path $url) $mountpoint"
9595
;;
96+
(sshfs)
97+
mount_cmd="sshfs $(url_host $url):$(url_path $url) $mountpoint -o $options"
98+
;;
9699
(*)
97100
mount_cmd="mount $v -t $(url_scheme $url) -o $options $(url_host $url):$(url_path $url) $mountpoint"
98101
;;
@@ -116,6 +119,9 @@ umount_url() {
116119
### Don't need to umount anything for these
117120
return 0
118121
;;
122+
(sshfs)
123+
umount_cmd="fusermount -u $mountpoint"
124+
;;
119125
(var)
120126
local var=$(url_host $url)
121127
umount_cmd="${!var} $mountpoint"

usr/share/rear/output/ISO/Linux-i386/90_transfer_image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local server=$(url_host $OUTPUT_URL)
1414
local path=$(url_path $OUTPUT_URL)
1515

1616
case "$scheme" in
17-
(nfs|cifs|usb|tape|file)
17+
(nfs|cifs|usb|tape|file|sshfs)
1818
# The ISO has already been transferred by NETFS.
1919
return 0
2020
;;

usr/share/rear/prep/NETFS/default/05_check_NETFS_requirements.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# example: usb:///dev/sdb1
55
# example: tape:///dev/nst0
66
# example: file:///path
7+
# example: sshfs://user@host/G/rear/
78

89
[[ "$BACKUP_URL" || "$BACKUP_MOUNTCMD" ]]
910
StopIfError "You must specify either BACKUP_URL or BACKUP_MOUNTCMD and BACKUP_UMOUNTCMD !"
@@ -13,22 +14,30 @@ if [[ "$BACKUP_URL" ]] ; then
1314
local scheme=$(url_scheme $BACKUP_URL)
1415
local path=$(url_path $BACKUP_URL)
1516

16-
### check if host is reachable
17-
if [[ "$PING" && "$host" ]]; then
18-
ping -c 2 "$host" >&8
19-
StopIfError "Backup host [$host] not reachable."
20-
else
21-
Log "Skipping ping test"
22-
fi
23-
2417
### set other variables from BACKUP_URL
2518
case $scheme in
2619
(usb)
2720
if [[ -z "$USB_DEVICE" ]] ; then
2821
USB_DEVICE="$path"
2922
fi
3023
;;
24+
(sshfs)
25+
# check if $host contains a '@' because then we use user@host format
26+
echo $host | grep -q '@' && {
27+
sshfs_user="${host%%@*}" # save the user
28+
host="${host#*@}" # remove user@
29+
}
30+
;;
3131
esac
32+
33+
### check if host is reachable
34+
if [[ "$PING" && "$host" ]]; then
35+
ping -c 2 "$host" >&8
36+
StopIfError "Backup host [$host] not reachable."
37+
else
38+
Log "Skipping ping test"
39+
fi
40+
3241
fi
3342

3443
# some backup progs require a different backuparchive name
@@ -64,5 +73,15 @@ bzip2
6473
xz
6574
)
6675

76+
[[ "$scheme" = "sshfs" ]] && { # see http://sourceforge.net/apps/mediawiki/fuse/index.php?title=SshfsFaq
77+
REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" sshfs )
78+
PROGS=( "${PROGS[@]}" fusermount mount.fuse )
79+
MODULES=( "${MODULES[@]}" fuse )
80+
MODULES_LOAD=( "${MODULES_LOAD[@]}" fuse )
81+
# as we're using SSH behind the scenes we need our keys/config file saved
82+
COPY_AS_IS=( "${COPY_AS_IS[@]}" $HOME/.ssh /etc/fuse.conf )
83+
}
84+
85+
6786
# include required modules, like nfs cifs ...
6887
MODULES=( "${MODULES[@]}" $(url_scheme $BACKUP_URL) )

0 commit comments

Comments
 (0)