diff options
author | William Harrington <kb0iic@berzerkula.org> | 2021-03-24 09:49:07 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2021-03-24 09:49:07 -0500 |
commit | 483f5b37f796bf217572768f241081ffc9a19cd8 (patch) | |
tree | eff69c39faa314cf323034f4978548f1887a4ef3 | |
parent | 933166af85d74989308aeda39361f16785bb4c3f (diff) |
Adjust from chapter6 back for chapter7 backup. Add additional directories.
-rw-r--r-- | chapter7/backup.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/chapter7/backup.sh b/chapter7/backup.sh new file mode 100644 index 0000000..a32aeb4 --- /dev/null +++ b/chapter7/backup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +FILE="${LFS_VER}-ch7-backup.tar.xz" +DIRS=(bin dev etc lib lib64 proc run sbin sources sys tools usr var) + +if [ -f "${LFS}/sources/chapter7/backup" ]; then + echo -e "${GRN}Backup found. Remove manually to backup again.${RST}" +else + + echo -ne "${GRN}Backing up ${YLW}${LFS}${GRN} to ${YLW}${FILE}${RST}... " + pushd "${LFS}" > /dev/null || exit 1 + sudo XZ_OPTS="-T${NUMPROCS} -e" tar cJpf "${HOME}"/"${FILE}" "${DIRS[@]}" & pid=$! + spinner "$pid" + retval=$? + if [ "$retval" -ne 0 ]; then + echo -e "${RED}Backup FAILED!${RST}" + else + sudo chown "${USER}" /home/"${USER}"/"${FILE}" + echo -e "${GRN}OK${RST}" + fi + popd > /dev/null || exit 1 + + touch "${LFS}/sources/chapter7/backup" +fi + |