Commit | Line | Data |
---|---|---|
99248ed2 MW |
1 | #! /bin/sh |
2 | ### -*-sh-*- | |
3 | ### | |
4 | ### Backup ext[2-4] filesystem using dump | |
5 | ### | |
6 | ### (c) 2011 Mark Wooding | |
7 | ### | |
8 | ||
9 | ###----- Licensing notice --------------------------------------------------- | |
10 | ### | |
11 | ### This program is free software; you can redistribute it and/or modify | |
12 | ### it under the terms of the GNU General Public License as published by | |
13 | ### the Free Software Foundation; either version 2 of the License, or | |
14 | ### (at your option) any later version. | |
15 | ### | |
16 | ### This program is distributed in the hope that it will be useful, | |
17 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ### GNU General Public License for more details. | |
20 | ### | |
21 | ### You should have received a copy of the GNU General Public License | |
22 | ### along with this program; if not, write to the Free Software Foundation, | |
23 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
24 | ||
25 | set -e | |
26 | . @pkglibdir@/bkpfunc.sh | |
27 | ||
28 | ## Check arguments and environment. | |
29 | preflight | |
30 | case $# in 0 | 1) echo >&2 "usage: $QUIS TAG DEVICE DUMPARGS ..." ;; esac | |
31 | tag=$1 device=$2; shift 2 | |
32 | ||
33 | ## Transform the date format. | |
34 | since=$(datefmt "%a %b %e %H:%M:%S %Y %z" "$BKP_LASTDATE") | |
35 | ||
36 | ## Make a snapshot and dump it. | |
37 | snap=$(snap "$device" tag=dump) | |
38 | set +e | |
39 | run \ | |
40 | env RSH=ssh RMT=$BKP_RMT \ | |
41 | dump -${BKP_LEVEL}q -z9 -T"$since" \ | |
42 | -f"$BKP_HOST:$BKP_ASSET/$tag.dump" -Q"$tag.qfa" \ | |
43 | "$@" \ | |
44 | "/dev/$snap" | |
45 | rc=$?; set -e | |
46 | snap -u "$device" tag=dump | |
47 | case $rc in 0) ;; *) exit $rc ;; esac | |
48 | ||
49 | scp "$BKP_HOST:$BKP_TARGET/$tag.dump.hash" "$tag.dump.hash" | |
50 | hash=$(cat "$tag.dump.hash") | |
51 | ssh "$BKP_HOST" rm "$BKP_TARGET/$tag.dump.hash" | |
52 | scp "$tag.qfa" "$BKP_HOST:$BKP_TARGET/$tag.qfa" | |
53 | bkpadmin hash "$BKP_ASSET" "$tag.dump" "$hash" | |
54 | ||
55 | ###----- That's all, folks -------------------------------------------------- |