bup index /etc
bup save -r SERVERNAME:path/to/remote-bup-dir -n local-etc /etc
- - Restore a backup from a remote server. (FAIL: unfortunately,
- unlike "bup join", "bup restore" does not yet support remote
- restores. See both "bup join" and "Things that are stupid" below.)
+ - Make a remote backup to ~/.bup on SERVER:
+
+ bup index /etc
+ bup save -r SERVER: -n local-etc /etc
+
+ - Restore the remote backup to ./dest:
+
+ bup restore -r SERVER: -C ./dest local-etc/latest/etc
+ ls -l dest/etc
- Defend your backups from death rays (OK fine, more likely from the
occasional bad disk block). This writes parity information
GIT_DIR=~/.bup git log local-etc
- - Make a backup on a remote server:
+ - Save a tar archive to a remote server (without tar -z to facilitate
+ deduplication):
tar -cvf - /etc | bup split -r SERVERNAME: -n local-etc -vv
- - Try restoring the remote backup tarball:
+ - Restore the archive:
bup join -r SERVERNAME: local-etc | tar -tf -
Help with any of these problems, or others, is very welcome. Join the
mailing list (see below) if you'd like to help.
- - 'bup restore' can't pull directly from a remote server.
-
- So in one sense "save -r" is a dead-end right now. Obviously you
- can use "ssh SERVER bup restore -C ./dest..." to create a tree you
- can transfer elsewhere via rsync/tar/whatever, but that's *lame*.
-
- Until we fix it, you may be able to mount the remote BUP_DIR via
- sshfs and then restore "normally", though that hasn't been
- officially tested.
-
- 'bup save' and 'bup restore' have immature metadata support.
On the plus side, they actually do have support now, but it's new,
from bup.helpers import (add_error, chunkyreader, die_if_errors, handle_ctrl_c,
log, mkdirp, parse_rx_excludes, progress, qprogress,
saved_errors, should_rx_exclude_path, unlink)
-from bup.repo import LocalRepo
+from bup.repo import LocalRepo, RemoteRepo
optspec = """
-bup restore [-C outdir] </branch/revision/path/to/dir ...>
+bup restore [-r host:path] [-C outdir] </branch/revision/path/to/dir ...>
--
+r,remote= remote repository path
C,outdir= change to given outdir before extracting files
numeric-ids restore numeric IDs (user, group, etc.) rather than names
exclude-rx= skip paths matching the unanchored regex (may be repeated)
mkdirp(opt.outdir)
os.chdir(opt.outdir)
- repo = LocalRepo()
+ repo = RemoteRepo(opt.remote) if opt.remote else LocalRepo()
top = os.getcwd()
hardlinks = {}
for path in extra:
bup() { "$top/bup" "$@"; }
+validate-local-and-remote-restore()
+{
+ local src="$1" dest="$2" cmp_src="$3" cmp_dest="$4"
+ force-delete "$dest"
+ WVPASS bup restore -C "$dest" "$src"
+ WVPASS "$top/t/compare-trees" "$cmp_src" "$cmp_dest"
+ force-delete "$dest"
+ WVPASS bup restore -r ":$BUP_DIR" -C "$dest" "$src"
+ WVPASS "$top/t/compare-trees" "$cmp_src" "$cmp_dest"
+}
+
+
WVPASS cd "$tmpdir"
WVSTART "init"
-
WVPASS bup init
-
D=bupdata.tmp
WVPASS force-delete $D
WVPASS mkdir $D
WVPASS bup index $D
WVPASS bup save -t $D
+
WVSTART "restore"
WVPASS force-delete buprestore.tmp
WVFAIL bup restore boink
WVPASS bup restore -C buprestore.tmp split_empty_string.tmp/latest/
WVPASSEQ "$(cat buprestore.tmp/data)" ""
+
(
tmp=testrestore.tmp
WVPASS force-delete $tmp
WVPASS bup save --strip -n foo $tmp/src
WVSTART "restore /foo/latest"
- WVPASS bup restore -C $tmp/restore /foo/latest
- WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/latest/
-
- WVSTART "restore /foo/latest/"
- WVPASS force-delete "$tmp/restore"
- WVPASS bup restore -C $tmp/restore /foo/latest/
- for x in $tmp/src/*; do
- WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
- done
+ validate-local-and-remote-restore \
+ /foo/latest "$tmp/restore" \
+ "$tmp/src/" "$tmp/restore/latest/"
WVSTART "restore /foo/latest/."
WVPASS force-delete "$tmp/restore"
- WVPASS bup restore -C $tmp/restore /foo/latest/.
- WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/
+ validate-local-and-remote-restore \
+ /foo/latest/. "$tmp"/restore \
+ "$tmp"/src/ "$tmp"/restore
WVSTART "restore /foo/latest/x"
WVPASS force-delete "$tmp/restore"
- WVPASS bup restore -C $tmp/restore /foo/latest/x
- WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/x/
+ validate-local-and-remote-restore \
+ /foo/latest/x "$tmp"/restore \
+ "$tmp"/src/x/ "$tmp"/restore/x/
WVSTART "restore /foo/latest/x/"
- WVPASS force-delete "$tmp/restore"
- WVPASS bup restore -C $tmp/restore /foo/latest/x/
- for x in $tmp/src/x/*; do
- WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
+ WVPASS force-delete "$tmp/restore"
+ WVPASS bup restore -C "$tmp"/restore /foo/latest/x/
+ for x in "$tmp"/src/x/*; do
+ WVPASS "$top/t/compare-trees" "$x/" "$tmp/restore/$(basename $x)"
+ done
+ WVPASS force-delete "$tmp/restore"
+ WVPASS bup restore -r ":$BUP_DIR" -C "$tmp"/restore /foo/latest/x/
+ for x in "$tmp"/src/x/*; do
+ WVPASS "$top/t/compare-trees" "$x/" "$tmp/restore/$(basename $x)"
done
WVSTART "restore /foo/latest/x/."
WVPASS force-delete "$tmp/restore"
- WVPASS bup restore -C $tmp/restore /foo/latest/x/.
- WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/
+ validate-local-and-remote-restore \
+ /foo/latest/x/. "$tmp"/restore \
+ "$tmp"/src/x/ "$tmp"/restore/
) || exit $?
WVPASS rm -r "$tmp"
) || exit $?
+
WVSTART "save disjoint top-level directories"
(
# Resolve any symlinks involving the top top-level dirs.
WVPASSEQ "$actual" "$expected"
) || exit $?
+
+WVPASS cd "$top"
WVPASS rm -rf "$tmpdir"