Nicer script formatting

This commit is contained in:
Wojciech Kozlowski 2019-12-14 23:15:20 +01:00
parent 0a6f06c5ac
commit 1123c1bd8c
3 changed files with 57 additions and 7 deletions

View File

@ -2,32 +2,69 @@
set -ue set -ue
# Import all account and GPG variables CYAN='\033[01;36m'
NC='\033[00m'
if [ -t 1 ]; then
CYAN=''
NC=''
fi
SCRIPT=$(readlink -f $0)
DIRNAME=$(dirname $SCRIPT)
# -----------------------------------------------------------------------------
# Import all account and GPG variables.
# -----------------------------------------------------------------------------
source ./b2.cred source ./b2.cred
export PASSPHRASE=${GPG_PASSPHRASE} export PASSPHRASE=${GPG_PASSPHRASE}
# Local directory to backup # -----------------------------------------------------------------------------
# Local directory to backup.
# -----------------------------------------------------------------------------
LOCAL_DIR="/media/usb0/backup" LOCAL_DIR="/media/usb0/backup"
# Remove files older than 30 days # -----------------------------------------------------------------------------
# Remove files older than 30 days.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Remove files older than 30 days ${NC}"
duplicity remove-older-than 30D --force \ duplicity remove-older-than 30D --force \
--encrypt-sign-key $GPG_KEY \ --encrypt-sign-key $GPG_KEY \
b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET} b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET}
# Perform a full backup # -----------------------------------------------------------------------------
# Perform a full backup.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Perform a full backup ${NC}"
duplicity full \ duplicity full \
--encrypt-sign-key $GPG_KEY \ --encrypt-sign-key $GPG_KEY \
${LOCAL_DIR} b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET} ${LOCAL_DIR} b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET}
# Cleanup failures # -----------------------------------------------------------------------------
# Clean up failures.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Clean up failures ${NC}"
duplicity cleanup --force \ duplicity cleanup --force \
--encrypt-sign-key $GPG_KEY \ --encrypt-sign-key $GPG_KEY \
b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET} b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET}
# Show collection-status # -----------------------------------------------------------------------------
# Show collection status.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Show collection status ${NC}"
duplicity collection-status \ duplicity collection-status \
--encrypt-sign-key $GPG_KEY \ --encrypt-sign-key $GPG_KEY \
b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET} b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET}
# Unset the GPG passphrase # -----------------------------------------------------------------------------
# Unset the GPG passphrase.
# -----------------------------------------------------------------------------
unset PASSPHRASE unset PASSPHRASE

View File

@ -8,6 +8,14 @@ YELLOW='\033[01;33m'
CYAN='\033[01;36m' CYAN='\033[01;36m'
NC='\033[00m' NC='\033[00m'
if [ -t 1 ]; then
RED=''
GREEN=''
YELLOW=''
CYAN=''
NC=''
fi
SCRIPT=$(readlink -f $0) SCRIPT=$(readlink -f $0)
DIRNAME=$(dirname $SCRIPT) DIRNAME=$(dirname $SCRIPT)

View File

@ -5,6 +5,11 @@ set -e
CYAN='\033[01;36m' CYAN='\033[01;36m'
NC='\033[00m' NC='\033[00m'
if [ -t 1 ]; then
CYAN=''
NC=''
fi
SCRIPT=$(readlink -f $0) SCRIPT=$(readlink -f $0)
DIRNAME=$(dirname $SCRIPT) DIRNAME=$(dirname $SCRIPT)