Absorb functionality
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 74 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 311 KiB After Width: | Height: | Size: 370 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
@@ -315,6 +315,35 @@ def main():
|
||||
t.cmd("ls Scans")
|
||||
shoot("migrate", t)
|
||||
|
||||
# absorb: a tar archive piped in, here pulled from a gzipped tarball
|
||||
box.write("Projects/website/index.html", "<h1>hello</h1>\n")
|
||||
box.write("Projects/website/css/site.css", "body{}\n")
|
||||
box.write("Projects/website/img/logo.png", os.urandom(24_311))
|
||||
t = Term(box)
|
||||
t.cmd("tar -czf website.tar.gz -C Projects website")
|
||||
t.cmd("vault absorb backups < website.tar.gz", P)
|
||||
t.cmd("tar -c recipes | vault absorb old", P)
|
||||
t.cmd("vault list backups", P)
|
||||
shoot("absorb", t)
|
||||
|
||||
# mirror: a tiny local site, served on localhost
|
||||
site = os.path.join(box.root, "site")
|
||||
for rel, body in {"index.html": '<a href="/about.html">About</a> <link href="/style.css">',
|
||||
"about.html": '<a href="/">Home</a> <img src="/img/me.png">',
|
||||
"style.css": "body{background:url(/img/bg.png)}",
|
||||
"img/me.png": "png", "img/bg.png": "png"}.items():
|
||||
os.makedirs(os.path.dirname(os.path.join(site, rel)), exist_ok=True)
|
||||
with open(os.path.join(site, rel), "w") as f:
|
||||
f.write(body)
|
||||
srv = subprocess.Popen([sys.executable, "-m", "http.server", "8000", "--bind", "127.0.0.1"],
|
||||
cwd=site, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
time.sleep(1)
|
||||
t = Term(box)
|
||||
t.cmd("vault mirror http://localhost:8000/ sites", P)
|
||||
t.cmd("vault get sites/localhost:8000/about.html && cat about.html", P)
|
||||
shoot("mirror", t)
|
||||
srv.terminate()
|
||||
|
||||
# errors
|
||||
t = Term(box)
|
||||
t.cmd("vault list", "hunter2", highlight=("incorrect",))
|
||||
|
||||
@@ -567,6 +567,22 @@ the whole site, one request at a time, into a folder named after its host.
|
||||
Links inside pages and stylesheets are rewritten to relative paths, so the
|
||||
copy still browses once you get it out. Only the same host is followed.
|
||||
|
||||
\subsection{From a tar archive: \texttt{absorb}}
|
||||
\cmd{absorb} reads a tar archive, gzipped or not, from standard input and
|
||||
stores every plain file in it, optionally under a folder:
|
||||
|
||||
\begin{verbatim}
|
||||
tar -cz photos | vault absorb backup
|
||||
ssh server 'tar -c /etc' | vault absorb server1
|
||||
vault absorb old < archive.tar.gz
|
||||
\end{verbatim}
|
||||
|
||||
Each file is encrypted straight from the stream, so nothing is unpacked to
|
||||
disk first. Directories need no entry of their own; links, devices and any
|
||||
name that tries to climb out with \file{..} are skipped with a note. If the
|
||||
archive stops halfway through a file, that file isn't stored and vault
|
||||
stops; everything before it is already safely in.
|
||||
|
||||
\subsection{Moving in: \texttt{migrate}}
|
||||
\cmd{migrate} works exactly like \cmd{add}, but deletes each original once
|
||||
it's safely stored, then tidies away any folders left empty. It won't take a
|
||||
|
||||
Reference in New Issue
Block a user