File: rdiff-backup-wrap

package info (click to toggle)
rdiff-backup 2.2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,640 kB
  • sloc: python: 24,129; javascript: 9,512; sh: 1,230; ansic: 580; makefile: 36
file content (60 lines) | stat: -rwxr-xr-x 1,762 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
# Copyright (C) 2020 Patrik Dufresne <patrik@ikus-soft.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
# rdiff-backup-wrap
#
# This script is used to help the migration from legacy version (v1.2.8)
# to new version (v2.0.0) by auto-detecting the remote rdiff-backup version
# and then launch the right version locally.

# Extract the source and destination from the arguments
for ARG in "$@"; do
    SOURCE=$DEST
    DEST=$ARG
done

# Check if the source is remote.
case "$SOURCE" in
    *::*) REMOTE_SOURCE=1 ;;
    *) REMOTE_SOURCE=0 ;;
esac

# Pick the right version of rdiff-backup
CMD=rdiff-backup	# default if nothing else is found

for cmd in rdiff-backup-1 rdiff-backup2
do
	if command -v "$cmd" 2>&1 > /dev/null
	then
		CMD="$cmd"
	fi
done

if [ $REMOTE_SOURCE -eq 1 ]; then
    if rdiff-backup --test-server "$SOURCE" 2>&1 > /dev/null; then
	CMD="rdiff-backup"
    else
	# because the version we found previously might also not work
	if ! "$CMD" --test-server "$SOURCE" 2>&1 > /dev/null; then
	    echo "ERROR:   Couldn't find a working version of rdiff-backup, tried 'rdiff-backup' and '$CMD'" >&2
	    exit 1
	fi
    fi
fi

exec "$CMD" "$@"