<ol>
<li>Creating Backups.</li>
</ol>
<ul>
<li><p>This script was trimmed to serve as an example.</p></li>
<li><p>The three options shown (email, jop, dots) demonstrates, how to list items with case statements:</p>
<ul>
<li>Single item/directory (jop).</li>
<li>Multiple items in single directory (dots).</li>
<li>Multiple items in multiple directories (email).</li>
</ul></li>
<li><p>The text files created after the archive serves as an item list<br />
with current permissions.</p></li>
<li><p><code>tar --directory= /path/to/directory/ --create --file INSERT_ARCHIVE_NAME.tar /path/to/file;</code></p></li>
</ul>
<pre><code>#!/bin/bash
#License: GPL v3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see &lt;https://www.gnu.org/licenses/&gt;.

#Name: getoverhere.sh
#Purpose:
#Version: beta 0.07
#Author: SGOTI (Some Guy On The Internet)
#Date: Sat 29 Jan 2022 02:19:29 AM EST

#variables:
VAR_TBALL=
VAR_TARGET=
VAR_JUMP=
VAR_VALUE=

#start:
cat &lt;&lt; &quot;EOT01&quot;
Options:
    email |&quot;${HOME}/.thunderbird/&quot;
    jop |&quot;${HOME}/Documents/joplin&quot;
    dots |&quot;${HOME}/.bashrc .vimrc .bash_aliases&quot;
EOT01

echo -e &quot;What do you want to backup? : \c.&quot;
read VAR_VALUE

case ${VAR_VALUE} in
    &quot;email&quot; )
VAR_TBALL=&quot;INSERT_EMAIL_NAME$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;msgFilterRules.dat&quot;
VAR_JUMP=&quot;${HOME}/.thunderbird/*.default-release/ImapMail/imap.mail.yahoo.com/&quot;
    echo -e &quot;Grabbing INSERT_EMAIL_NAME...\n&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    sleep 1

VAR_TBALL=&quot;INSERT_EMAIL_NAME$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;msgFilterRules.dat&quot;
VAR_JUMP=&quot;${HOME}/.thunderbird/*.default-release/ImapMail/imap.gmail.com/&quot;
    echo -e &quot;Grabbing INSERT_EMAIL_NAME...\n&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    sleep 1

VAR_TBALL=&quot;EMAIL_ARCHIVES$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;Mail/&quot;
VAR_JUMP=&quot;${HOME}/.thunderbird/*.default-release/&quot;
    echo -e &quot;Grabbing email EMAIL_ARCHIVES...\n&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    echo -e &quot;Creating List for ${VAR_TBALL}...\n&quot;
ls -lhAR --group-directories-first ${VAR_JUMP}${VAR_TARGET} &gt; EMAIL_ARCHIVES$(date +%m-%d-%Y).txt
    sleep 1

VAR_TBALL=&quot;THUNDERBIRD_CALENDER$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;calenders/&quot;
VAR_JUMP=&quot;${HOME}/Documents/&quot;
    echo -e &quot;Grabbing email THUNDERBIRD_CALENDER...\n&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    echo -e &quot;Creating List for ${VAR_TBALL}...\n&quot;
ls -lhAR --group-directories-first ${VAR_JUMP}${VAR_TARGET} &gt; THUNDERBIRD_CALENDER$(date +%m-%d-%Y).txt
    sleep 1

VAR_TBALL=&quot;THUNDERBIRD_ADDRESS_BOOK$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;address-book/&quot;
VAR_JUMP=&quot;${HOME}/Documents/&quot;
    echo -e &quot;Grabbing ${VAR_TARGET}...\n&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    echo -e &quot;Creating List for ${VAR_TBALL}...\n&quot;
ls -lhAR --group-directories-first ${VAR_JUMP}${VAR_TARGET} &gt; THUNDERBIRD_ADDRESS_BOOK$(date +%m-%d-%Y).txt
    sleep 1

VAR_TBALL=&quot;THUNDERBIRD_ALL$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;.thunderbird/&quot;
VAR_JUMP=&quot;${HOME}/&quot;
    echo -e &quot;Grabbing ${VAR_TARGET}...\n&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    echo -e &quot;Creating List for ${VAR_TBALL}...\n&quot;
ls -lhAR --group-directories-first ${VAR_JUMP}${VAR_TARGET} &gt; THUNDERBIRD_ALL$(date +%m-%d-%Y).txt ;;

    &quot;jop&quot; )
VAR_TBALL=&quot;JOPLIN$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;joplin/&quot;
VAR_JUMP=&quot;${HOME}/Documents/&quot;
    echo &quot;Grabbing ${VAR_TARGET}&quot;
tar -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET}
    sleep 1
    echo -e &quot;Creating List for ${VAR_TBALL}...\n&quot;
ls -lhAR --group-directories-first ${VAR_JUMP}${VAR_TARGET} &gt; JOPLIN$(date +%m-%d-%Y).txt ;;

    &quot;dots&quot; )
VAR_TBALL=&quot;dots$(date +%m-%d-%Y).tar.gz&quot;
VAR_TARGET=&quot;.bashrc .vimrc .bash_aliases&quot;
VAR_JUMP=&quot;${HOME}/&quot;
    echo &quot;Grabbing ${VAR_TARGET}&quot;
tar -v -C ${VAR_JUMP} --create --file ${VAR_TBALL} --gzip ${VAR_TARGET} ;;

    * )
    echo &quot;Good Heavens...&quot; ;;
esac
exit;
</code></pre>
<hr />
<ol start="2">
<li>Restoring from backups.</li>
</ol>
<ul>
<li><code>tar --extract --directory= /path/to/directory/ --file /path/to/file;</code></li>
<li>A <code>cp -v -t /path/to/directory *08-05-2022.tar.gz;</code> command is used to<br />
send the latest tarballs to the fresh install, from the backup drive.</li>
<li>Now that you&#x2019;ve seen the script above, I&#x2019;ll just give a <code>tar --extract</code> example to keep things short and sweet.</li>
</ul>
<pre><code>VAR_TBALL=&quot;EMAIL_ARCHIVES*.tar.gz&quot;
VAR_JUMP=&quot;${HOME}/.thunderbird/*.default-release/&quot;
    echo -e &quot;Restoring EMAIL_ARCHIVES...\n&quot;
tar --extract --directory= ${VAR_JUMP} --file ${VAR_TBALL}
    echo -e &quot;EMAIL_ARCHIVES restored.\n&quot;
</code></pre>
