Debian Codegraph @

lib/cmd/bup-import-rsnapshot

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Does an import of a rsnapshot archive.
3
4 cmd_dir="$(cd "$(dirnamescip-shell system . . dirname. "$0")" && pwdscip-shell system . . pwd.)" || exit $?
5
6 usagescip-shell shell bup 0.33.10-1 usage().() {
7 echoscip-shell system . . echo. "Usage: bup import-rsnapshot [-n]" \
8 "<path to snapshot_root> [<backuptarget>]"
9 echoscip-shell system . . echo. "-n,--dry-run: just print what would be done"
10 exit 1
11 }
12
13 DRY_RUN=
14 while [scip-shell system . . `[`. "$1" = "-n" -o "$1" = "--dry-run" ]; do
15 DRY_RUN=echo
16 shift
17 done
18
19 bupscip-shell shell bup 0.33.10-1 bup().()
20 {
21 $DRY_RUN "$cmd_dir/bup" "$@"
22 }
23
24 SNAPSHOT_ROOT=$1
25 TARGET=$2
26
27 [scip-shell system . . `[`. -n "$SNAPSHOT_ROOT" -a "$#" -le 2 ] || usagescip-shell shell bup 0.33.10-1 usage().
28
29 if [scip-shell system . . `[`. ! -e "$SNAPSHOT_ROOT/." ]; then
30 echoscip-shell system . . echo. "'$SNAPSHOT_ROOT' isn't a directory!"
31 exit 1
32 fi
33
34
35 cd "$SNAPSHOT_ROOT" || exit 2
36
37 for SNAPSHOT in *; do
38 [scip-shell system . . `[`. -e "$SNAPSHOT/." ] || continue
39 echoscip-shell system . . echo. "snapshot='$SNAPSHOT'" >&2
40 for BRANCH_PATH in "$SNAPSHOT/"*; do
41 BRANCH=$(basenamescip-shell system . . basename. "$BRANCH_PATH") || exit $?
42 [scip-shell system . . `[`. -e "$BRANCH_PATH/." ] || continue
43 [scip-shell system . . `[`. -z "$TARGET" -o "$TARGET" = "$BRANCH" ] || continue
44
45 echoscip-shell system . . echo. "snapshot='$SNAPSHOT' branch='$BRANCH'" >&2
46
47 # Get the snapshot's ctime
48 DATE=$(perlscip-shell system . . perl. -e '@a=stat($ARGV[0]) or die "$ARGV[0]: $!";
49 print $a[10];' "$BRANCH_PATH")
50 [scip-shell system . . `[`. -n "$DATE" ] || exit 3
51
52 TMPIDX=bupindex.$BRANCH.tmp
53 bupscip-shell shell bup 0.33.10-1 bup(). index -ux -f "$TMPIDX" "$BRANCH_PATH/" || exit $?
54 bupscip-shell shell bup 0.33.10-1 bup(). save --strip --date="$DATE" \
55 -f "$TMPIDX" -n "$BRANCH" \
56 "$BRANCH_PATH/" || exit $?
57 rmscip-shell system . . rm. "$TMPIDX" || exit $?
58 done
59 done