aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2016-07-24 17:47:56 +0200
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2016-07-24 17:47:56 +0200
commit0301342f0906ad5fad0cd2caf7ac2e44014c724a (patch)
treeadc953d2f499af951aebafb769cdb12756e1467e
parentCheck if PIDs file exists (diff)
downloadbackuper-0301342f0906ad5fad0cd2caf7ac2e44014c724a.tar.xz
Drop personalization process and replace it with configuration
-rw-r--r--backuper.sh35
1 files changed, 25 insertions, 10 deletions
diff --git a/backuper.sh b/backuper.sh
index 95e3c25..d36e436 100644
--- a/backuper.sh
+++ b/backuper.sh
@@ -1,7 +1,8 @@
## Some default values of important variables
## Settings
-GPG_RECIPIENT="robin.oburka@nic.cz"
+GPG_RECIPIENTS=""
+MBUFFER_SIZE="100M"
## Internal variables - backup process
NAME=""
@@ -20,7 +21,7 @@ PID_FILE="pids"
STAGE="0"
## Internal variables - program logic
-PERSN_FILE_NAME=".backuper.sh.per"
+CONFIG_FILE_NAME=".backuper.sh.conf"
## Output helpers
title() {
@@ -54,6 +55,13 @@ result_file() {
fi
}
+compute_gpg_recipients() {
+ GPG_RECIPIENTS_LIST=""
+ for R in $GPG_RECIPIENTS; do
+ GPG_RECIPIENTS_LIST=" --recipient "$R""
+ done
+}
+
## Program control
error() {
echo "ERROR: $1" >&2
@@ -125,6 +133,7 @@ test_input() {
[ -z "$COMMAND" -a -z "$PLACES" ] && error "Specify backup subject"
[ -n "$COMMAND" -a -n "$PLACES" ] && error "Do not specify two types of backup at once"
[ -z "$STORE" ] && error "Specify store command"
+ [ -z "$GPG_RECIPIENTS" ] && error "Set GPG recipient for encrypted backups"
}
compute_variables() {
@@ -133,6 +142,7 @@ compute_variables() {
FILENAME="backup_"$NAME"_"$TS".tar"
FILENAME_ENC="${FILENAME}.bz2.gpg"
RUNDIR="/tmp/backuper_run_dir_$$_$UTS"
+ compute_gpg_recipients
}
prepare() {
@@ -176,9 +186,9 @@ backup_done() {
fi
}
-personalization() {
+load_config() {
HOME="$(get_home)"
- [ -f "$HOME"/"$PERSN_FILE_NAME" ] && . "$HOME"/"$PERSN_FILE_NAME"
+ [ -f "$HOME"/"$CONFIG_FILE_NAME" ] && . "$HOME"/"$CONFIG_FILE_NAME"
}
add_stage() {
@@ -211,14 +221,14 @@ start_command() {
}
start_pipeline() {
- add_stage "mbuffer -q -m 100M"
+ add_stage "mbuffer -q -m "$MBUFFER_SIZE""
add_stage "pbzip2"
- add_stage "mbuffer -q -m 100M"
- add_stage "gpg -z0 -r robin.oburka@nic.cz -e"
+ add_stage "mbuffer -q -m "$MBUFFER_SIZE""
+ add_stage "gpg -z0 $GPG_RECIPIENTS_LIST -e"
## OK, this is strange. If store command fail, mbuffer forks itself with
## PID that I'm not able to get (event from list of children).
## ... and it takes 100% CPU. So, for now: Do not use mbuffer as the last one.
- #add_stage "mbuffer -q -m 100M"
+ #add_stage "mbuffer -q -m "$MBUFFER_SIZE""
start_store || die "Store command failed" &
PID_STORE=$!
@@ -233,10 +243,15 @@ start_pipeline() {
}
backup() {
- test_input
prepare
- personalization
+ test_input
start_pipeline
backup_done
cleanup
}
+
+main() {
+ load_config
+}
+
+main