diff options
-rw-r--r-- | backuper.sh | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/backuper.sh b/backuper.sh index 8acc4b6..5c71822 100644 --- a/backuper.sh +++ b/backuper.sh @@ -8,8 +8,7 @@ TIME_FMT="Time:\t%E" ## Internal variables NAME="" -DST_COMMAND="" -#GENERATE="sudo" +REMOTE="" GENERATE="" COMMAND="" PLACES="" @@ -26,10 +25,16 @@ test_input() { [ -z "$NAME" ] && error "Specify backup name" [ -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" } name() { NAME="$1" + compute_variables +} + +remote() { + REMOTE="$1" } generate() { @@ -81,7 +86,7 @@ compute_variables() { UTS="$(date +"%s")" TS="$(date +"%Y-%m-%d_%H-%M-%S")" FILENAME="backup_"$NAME"_"$TS".tar" - FILENAME_ENC="$FILENAME".gpg + FILENAME_ENC="${FILENAME}.bz2.gpg" RUNDIR="/tmp/backuper_run_dir_$$_$UTS" } @@ -148,23 +153,26 @@ add_stage() { } start_store() { + echo "$STORE" $STORE < "$RUNDIR"/fifo_"$NEXTSTAGE" } start_command() { + title "Create backup" if [ -n "$COMMAND" ]; then - echo "$COMMAND" | $GENERATE sh -s > "$RUNDIR"/fifo_0 + echo "$COMMAND" | $REMOTE $GENERATE sh -s > "$RUNDIR"/fifo_0 else ## Exclude keep without quotes - /usr/bin/time -f "$TIME_FMT" $GENERATE tar c --preserve-permissions $EXCLUDE "$PLACES" > "$RUNDIR"/fifo_0 + /usr/bin/time -f "$TIME_FMT" $REMOTE $GENERATE tar c --preserve-permissions $EXCLUDE "$PLACES" > "$RUNDIR"/fifo_0 fi } start_pipeline() { - add_stage cat - add_stage cat - add_stage cat - add_stage cat + add_stage "mbuffer -q -m 100M" + add_stage "pbzip2" + add_stage "mbuffer -q -m 100M" + add_stage "gpg -z0 -r robin.oburka@nic.cz -e" + add_stage "mbuffer -q -m 100M" start_store || die & PID_STORE=$! @@ -178,21 +186,18 @@ start_pipeline() { done } -#create_backup() { -# title "Create" -# -# if [ -n "$PLACES" ]; then -# backup_tar | cat > "$DST"/"$FILENAME" -# elif [ -n "$COMMAND" ]; then -# echo "Generating with command: $COMMAND" -# backup_cmd | cat > "$DST"/"$FILENAME" -# else -# error "There is no generating command" -# fi -# -# printf "Backup:\t%s (%s)\n\n" "$FILENAME" "$(get_size "$DST"/"$FILENAME")" -#} -# +run() { + title "Run command" + echo "$@" + echo $@ | $REMOTE sh -s + printf "\n" +} + +store_file() { + [ -z "$1" ] && error "Specify destination" + store "sh -c 'cat > ${1}/${FILENAME_ENC}'" +} + #enc() { # title "Encrypt" # /usr/bin/time -f "$TIME_FMT" gpg --compress-algo zlib --recipient "$GPG_RECIPIENT" -e "$DST"/"$FILENAME" @@ -201,23 +206,10 @@ start_pipeline() { # printf "Encrypted backup:\t%s (%s)\n\n" "$FILENAME_ENC" "$(get_size "$DST"/"$FILENAME_ENC")" #} # -#run() { -# title "Run command" -# echo "$@" -# CMD="sh -c \"$@\"" -# echo $@ | $GENERATE sh -s -# printf "\n" -#} backup() { test_input - compute_variables prepare start_pipeline - #kill $$ cleanup - #create_backup - #secure - #enc - #send } |