mirror of
https://github.com/YunoHost-Apps/borg_ynh.git
synced 2024-09-03 18:16:05 +02:00
backup_method coding style
This commit is contained in:
parent
5e2f1e7910
commit
75c2765211
1 changed files with 13 additions and 15 deletions
|
@ -1,13 +1,12 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
set -eo pipefail
|
source "__INSTALL_DIR__/venv/bin/activate"
|
||||||
source __INSTALL_DIR__/venv/bin/activate
|
app="__APP__"
|
||||||
|
|
||||||
app="${0#"./05-"}"
|
BORG_PASSPHRASE="$(yunohost app setting "$app" passphrase)"
|
||||||
app="${app%"_app"}"
|
repo="$(yunohost app setting "$app" repository)" #$4
|
||||||
|
|
||||||
BORG_PASSPHRASE="$(yunohost app setting $app passphrase)"
|
|
||||||
repo="$(yunohost app setting $app repository)" #$4
|
|
||||||
if ssh-keygen -F "__SERVER__" >/dev/null ; then
|
if ssh-keygen -F "__SERVER__" >/dev/null ; then
|
||||||
BORG_RSH="ssh -i /root/.ssh/id_${app}_ed25519 -oStrictHostKeyChecking=yes "
|
BORG_RSH="ssh -i /root/.ssh/id_${app}_ed25519 -oStrictHostKeyChecking=yes "
|
||||||
else
|
else
|
||||||
|
@ -20,11 +19,10 @@ do_need_mount() {
|
||||||
|
|
||||||
LOGFILE=/var/log/backup_borg.err
|
LOGFILE=/var/log/backup_borg.err
|
||||||
log_with_timestamp() {
|
log_with_timestamp() {
|
||||||
sed -e "s/^/[$(date +"%Y-%m-%d_%H:%M:%S")] /" | tee -a $LOGFILE
|
sed -e "s/^/[$(date +"%Y-%m-%d_%H:%M:%S")] /" | tee -a $LOGFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
do_backup() {
|
do_backup() {
|
||||||
|
|
||||||
export BORG_PASSPHRASE
|
export BORG_PASSPHRASE
|
||||||
export BORG_RSH
|
export BORG_RSH
|
||||||
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
||||||
|
@ -37,11 +35,11 @@ do_backup() {
|
||||||
pushd "$work_dir"
|
pushd "$work_dir"
|
||||||
set +e
|
set +e
|
||||||
if borg init -e repokey "$repo" ; then
|
if borg init -e repokey "$repo" ; then
|
||||||
#human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'`
|
# human_size=`echo $size | awk '{ suffix=" KMGT"; for(i=1; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'`
|
||||||
# Speed in Kbps
|
# Speed in Kbps
|
||||||
#speed=1000
|
# speed=1000
|
||||||
#evaluated_time=$(($size / ($speed * 1000 / 8) / 3600))
|
# evaluated_time=$(($size / ($speed * 1000 / 8) / 3600))
|
||||||
echo "Hello,
|
echo "Hello,
|
||||||
|
|
||||||
Your first backup on $repo is starting.
|
Your first backup on $repo is starting.
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@ case "$1" in
|
||||||
do_backup "$work_dir" "$name" "$repo" "$size" "$description"
|
do_backup "$work_dir" "$name" "$repo" "$size" "$description"
|
||||||
;;
|
;;
|
||||||
mount)
|
mount)
|
||||||
do_mount
|
do_mount "$work_dir" "$name" "$repo" "$size" "$description"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "hook called with unknown argument \`$1'" >&2
|
echo "hook called with unknown argument \`$1'" >&2
|
||||||
|
|
Loading…
Add table
Reference in a new issue