From 64cfcc2f1e1207f5da5a33cd0695b980fb360808 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Mon, 4 Nov 2024 19:30:25 -0500 Subject: [PATCH] Updated backup functions to include system and firefox --- .bashrc.d/backup-func | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.bashrc.d/backup-func b/.bashrc.d/backup-func index 1be3343..c368ede 100644 --- a/.bashrc.d/backup-func +++ b/.bashrc.d/backup-func @@ -1,3 +1,40 @@ +function backup-firefox() { + local archive="$1" + local target="$2" + local hostname + local date + + if [[ -z "$1" ]]; then + archive="$(grep -E '^ID=' /etc/os-release | cut -d'=' -f2)$(grep -E '^VERSION_ID=' /etc/os-release | cut -d'=' -f2)" + if [[ -z "$archive" ]]; then + archive="latest" + fi + fi + + if [[ -z "$2" ]]; then + if [[ -d "/mnt/storage/psi-jack/Backups" ]]; then + target="/mnt/storage/psi-jack/Backups" + else + target="/home/psi-jack/Backups" + fi + fi + + if [[ -f "/etc/hostname" ]]; then + hostname=$(< /etc/hostname) + else + hostname=$(hostname) + fi + + date=$(date +"%Y-%m-%d") + + mkdir -p "${target}/${archive}/${hostname}" + + pushd "$HOME/.mozilla" &>/dev/null + tar -cvvf "${target}/${archive}/${hostname}/${hostname}-${date}_firefox.tar" firefox + zstd --rm -6 "${target}/${archive}/${hostname}/${hostname}-${date}_firefox.tar" + popd &>/dev/null +} + function backup-home() { local archive="$1" local target="$2"