From 2c8204d6325a1a6607392d5905227b9043da17cc Mon Sep 17 00:00:00 2001 From: William Harrington Date: Sat, 11 Dec 2021 00:52:08 -0600 Subject: Major updates. --- chapter6/backup.sh | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'chapter6/backup.sh') diff --git a/chapter6/backup.sh b/chapter6/backup.sh index f9a761c..f93f37d 100644 --- a/chapter6/backup.sh +++ b/chapter6/backup.sh @@ -1,28 +1,28 @@ -#!/bin/bash -set -e - -file="${LFS_VER}-ch6-backup.tar.xz" -directories=(bin etc lib lib64 sbin tools usr var) - -if [ -f "${LFS}/sources/chapter6/backup" ]; then - printf "%b" " ${IGRN}Backup previously completed${RST}\n" -else - - printf "%b" "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${file}${RST}... " - pushd "${LFS}" > /dev/null || exit 1 - # shellcheck disable=SC2024 - sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJvpf "${HOME}"/"${file}" "${directories[@]}" >/"${LFS}"/sources/log/chapter6/backup.log 2>&1 & pid=$! - spinner "$pid" "${SPINNER}" - retval=$? - if [ "$retval" -ne 0 ]; then - fail "FAILED!" - exit "${retval}" - else - # shellcheck disable=SC2024 - sudo chown -v "${USER}":"$(id -g)" "${HOME}"/"${file}" >>"${LFS}"/sources/log/chapter6/backup.log - success "OK" - fi - popd > /dev/null || exit 1 - - touch "${LFS}"/sources/chapter6/backup -fi +#!/bin/bash +set -e + +file="${LFS_VER}-ch6-backup.tar.xz" +directories=(bin etc lib lib64 sbin tools usr var) + +if [ -f "${LFS}/sources/chapter6/backup" ]; then + printf "%b" " ${IGRN}Backup previously completed${RST}\n" +else + + printf "%b" "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${file}${RST}... " + pushd "${LFS}" > /dev/null || exit 1 + # shellcheck disable=SC2024 + sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJvpf "${HOME}"/"${file}" "${directories[@]}" >/"${LFS}"/sources/log/chapter6/backup.log 2>&1 & pid=$! + spinner "$pid" "${SPINNER}" + retval=$? + if [ "$retval" -ne 0 ]; then + fail "FAILED!" + exit "${retval}" + else + # shellcheck disable=SC2024 + sudo chown -v "${USER}":"$(id -g)" "${HOME}"/"${file}" >>"${LFS}"/sources/log/chapter6/backup.log + success "OK" + fi + popd > /dev/null || exit 1 + + touch "${LFS}"/sources/chapter6/backup +fi -- cgit v1.2.3-54-g00ecf