sh.zio.backup: add ability to run arbitrary restic commands
parent
229cee2f31
commit
82b10ba696
|
@ -21,10 +21,9 @@ function download_restic() {
|
|||
restic_path="/tmp/restic-$restic_version"
|
||||
restic_archive_path="${restic_path}_$(date +%s).${restic_download_url##*.}"
|
||||
|
||||
if [[ ! -f "$restic_path" ]]; then
|
||||
say info "Downloading Restic ($restic_version)..."
|
||||
|
||||
rm -f "$restic_path"
|
||||
|
||||
curl -L -s -o "$restic_archive_path" "$restic_download_url"
|
||||
bzip2 -dc "$restic_archive_path" > "$restic_path"
|
||||
rm -f "$restic_archive_path"
|
||||
|
@ -33,6 +32,8 @@ function download_restic() {
|
|||
|
||||
if [[ ! "$(echo "$("$restic_path" version)")" == "restic $restic_version"* ]]; then
|
||||
die "Unexpected output from '$restic_path version'"
|
||||
rm -f "$restic_path"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ function invoke_restic() {
|
|||
if [[ -z $command ]]; then
|
||||
say warning "No command specified. Not running"
|
||||
elif [[ $command == "self-update" ]]; then
|
||||
say warning "Command 'self-update' not supported. Not running"
|
||||
say warning "Command '$command' not supported. Not running"
|
||||
else
|
||||
"$restic_path" \
|
||||
--cache-dir "$cache_dir" \
|
||||
|
@ -159,6 +160,7 @@ download_restic 0.16.0
|
|||
test_file "$restic_repo_file"
|
||||
test_file "$restic_repo_passwd_file"
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
say info "Running backup scripts..."
|
||||
|
||||
if ! [[ "$(ls -A $backup_scripts_dir)" ]]; then
|
||||
|
@ -195,5 +197,9 @@ for backup_script in $backup_scripts_dir/*; do
|
|||
done
|
||||
|
||||
say primary "$(repeat "-" 80)"
|
||||
|
||||
#sudo rm -f "$restic_path"
|
||||
else
|
||||
command="$1"
|
||||
arguments="${@:2}"
|
||||
say info "Running: $restic_path $command $arguments"
|
||||
invoke_restic $command $arguments
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue