~mclehman/wrapper-borg

c5050b9e793291536b59dd932389317b424d20d7 — 0xFORDCOMMA 4 years ago master
Initial commit.
4 files changed, 49 insertions(+), 0 deletions(-)

A .gitignore
A META6.json
A lib/Wrapper/Borg.pm6
A lib/Wrapper/Borg.rakumod
A  => .gitignore +1 -0
@@ 1,1 @@
.precomp

A  => META6.json +22 -0
@@ 1,22 @@
{
  "scripts": {
    "test": "zef test ."
  },
  "description": "",
  "perl": "v6.*",
  "license": "https://opensource.org/licenses/GPL-3.0",
  "version": "2020.01.01",
  "authors": [
    "0xford"
  ],
  "tags": [
    "borg",
    "backup",
    "wrapper"
  ],
  "production": false,
  "name": "wrapper-borg",
  "provides": {
    "Wrapper::Borg": "lib/Wrapper/Borg.rakumod"
  }
}

A  => lib/Wrapper/Borg.pm6 +1 -0
@@ 1,1 @@
Borg.rakumod
\ No newline at end of file

A  => lib/Wrapper/Borg.rakumod +25 -0
@@ 1,25 @@
unit module Wrapper::Borg;

sub current-epoch() { now.to-posix.head.truncate }

multi flagify(Bool $value, $name) { $value ?? "-$name" !! "" }
multi flagify(     $value, $name) { "-$name", "$value" }

# sub strip-sigil($name) { $name.subst: /^['$' | '@' | '%' | '&']/, '' }

sub borg-create(
    *@dirs,
    :$repo!,
    :$archive = $repo.IO.basename.split('-').tail ~ '-' ~ current-epoch,
    Bool :$progress = True,
    Bool :$stats = True,
    :$compression = 'zstd,8'
) is export {
    my @args = ['create',
               |[$progress,    '-progress',
                 $stats,       '-stats',
                 $compression, '-compression'].map(&flagify),
              $repo ~ '::' ~ $archive,
              |@dirs];
    return Proc::Async.new: "borg", @args;
}