sh.zio.backup: add dump command
parent
59b61f60af
commit
2ef6caa499
|
@ -196,6 +196,7 @@ function prune_backup() {
|
||||||
|
|
||||||
function get_dump_dir() {
|
function get_dump_dir() {
|
||||||
service="$1"
|
service="$1"
|
||||||
|
|
||||||
specific_dumps_dir="/srv/dumps/$host/$service/$(date +"%Y%m%d%H%M%S")"
|
specific_dumps_dir="/srv/dumps/$host/$service/$(date +"%Y%m%d%H%M%S")"
|
||||||
mkdir -p "$specific_dumps_dir"
|
mkdir -p "$specific_dumps_dir"
|
||||||
[[ $? == "0" ]] && echo "$specific_dumps_dir"
|
[[ $? == "0" ]] && echo "$specific_dumps_dir"
|
||||||
|
@ -225,6 +226,9 @@ Usage:
|
||||||
$me_filename <script>
|
$me_filename <script>
|
||||||
Run a specific script from a given path
|
Run a specific script from a given path
|
||||||
|
|
||||||
|
$me_filename dump <snapshot ID>
|
||||||
|
Restore <snapshot ID> to /srv/dumps/$host/restic/<snapshot ID>/
|
||||||
|
|
||||||
$me_filename <command> [arguments]
|
$me_filename <command> [arguments]
|
||||||
Execute 'restic' with arbitrary commands and optional arguments
|
Execute 'restic' with arbitrary commands and optional arguments
|
||||||
|
|
||||||
|
@ -282,11 +286,19 @@ if [[ -z "$1" || -f "$1" ]]; then
|
||||||
--host "$host" \
|
--host "$host" \
|
||||||
--tag "$(basename "$0")" \
|
--tag "$(basename "$0")" \
|
||||||
| sed -E ":begin;$!N;s/$(basename "$0")\n\s+?//;tbegin;P;D"
|
| sed -E ":begin;$!N;s/$(basename "$0")\n\s+?//;tbegin;P;D"
|
||||||
|
elif [[ "$1" == "dump" ]]; then
|
||||||
|
snapshot="$2"
|
||||||
|
|
||||||
|
[[ -z "$snapshot" ]] && die "No snapshot ID provided"
|
||||||
|
|
||||||
|
invoke_restic restore \
|
||||||
|
--target "/srv/dumps/$host/restic/$snapshot" \
|
||||||
|
"$snapshot"
|
||||||
else
|
else
|
||||||
command="$1"
|
command="$1"
|
||||||
arguments="${@:2}"
|
arguments="${@:2}"
|
||||||
|
|
||||||
[[ $command = "purge" ]] && command="prune"
|
[[ $command == "purge" ]] && command="prune"
|
||||||
|
|
||||||
say info "Running: $restic_path $command $arguments"
|
say info "Running: $restic_path $command $arguments"
|
||||||
invoke_restic $command $arguments
|
invoke_restic $command $arguments
|
||||||
|
|
Loading…
Reference in New Issue