From d49ad449debcc57fdaf155e97481740a046dc5c9 Mon Sep 17 00:00:00 2001 From: Marco Cetica Date: Mon, 20 Mar 2023 11:42:51 +0100 Subject: [PATCH] Updated documentation and fixed bug on extract function --- README.md | 2 +- backup.sh | 5 +++-- backup.sh.1 | 2 +- man.md | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 005d3ef..ccf7aec 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ After that, you will find the final backup archive in `/home/john/backup- sudo crontab -e -30 03 * * 6 EKEY=$(cat /home/john/.ekey) /usr/local/bin/backup.sh -b /usr/local/etc/sources.bk /home/john $EKEY +30 03 * * 6 EKEY=$(cat /home/john/.ekey) bash -c '/usr/local/bin/backup.sh -b /usr/local/etc/sources.bk /home/john $EKEY' > /dev/null 2>&1 ``` diff --git a/backup.sh b/backup.sh index 373125e..fdd6c6d 100755 --- a/backup.sh +++ b/backup.sh @@ -109,9 +109,10 @@ extract_backup() { BACKUP_SH_ARCHIVE_PATH="$1" BACKUP_SH_ARCHIVE_PW="$2" - openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -d \ + (openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -salt -d \ -in "$BACKUP_SH_ARCHIVE_PATH" \ - -k "$BACKUP_SH_ARCHIVE_PW" | tar xvz + -k "$BACKUP_SH_ARCHIVE_PW" | tar xvz) > /dev/null 2>&1 \ + || (echo "Unable to extract backup." && exit 1) } helper() { diff --git a/backup.sh.1 b/backup.sh.1 index 8c72a90..b73d8ec 100644 --- a/backup.sh.1 +++ b/backup.sh.1 @@ -144,7 +144,7 @@ You can also use \f[B]backup.sh\f[R] from a crontab rule: .nf \f[C] $> sudo crontab -e -30 03 * * 6 EKEY=$(cat /home/john/.ekey) /usr/local/bin/backup.sh -b /usr/local/etc/sources.bk /home/john $EKEY +30 03 * * 6 EKEY=$(cat /home/john/.ekey) bash -c \[aq]/usr/local/bin/backup.sh -b /usr/local/etc/sources.bk /home/john $EKEY\[aq] > /dev/null 2>&1 \f[R] .fi .PP diff --git a/man.md b/man.md index e898fd2..eb0bf88 100644 --- a/man.md +++ b/man.md @@ -94,7 +94,7 @@ You can also use **backup.sh** from a crontab rule: ``` $> sudo crontab -e -30 03 * * 6 EKEY=$(cat /home/john/.ekey) /usr/local/bin/backup.sh -b /usr/local/etc/sources.bk /home/john $EKEY +30 03 * * 6 EKEY=$(cat /home/john/.ekey) bash -c '/usr/local/bin/backup.sh -b /usr/local/etc/sources.bk /home/john $EKEY' > /dev/null 2>&1 ``` This will automatically run **backup.sh** every Saturday morning at 03:30 AM.