backup.sh
#sets the current date and time to a variable so it can be used when naming zip file
current_time=$(date ā+%Y-%m-%d_%H.%M.%Sā)
#compress contents of /var folder to zip file
tar -zcvf /mnt/EXTHD01/fedora01/backup/fedora01_$current_time.tar.gz /var
#compress contents of /opt to zip file
tar -zcvf /mnt/EXTHD01/fedora01/backup/fedora01_$current_time.tar.gz /opt
#compress contents of /etc to zip file
tar -zcvf /mnt/EXTHD01/fedora01/backup/fedora01_$current_time.tar.gz /etc
#compress contents of /home to zip file
tar -zcvf /mnt/EXTHD01/fedora01/backup/fedora01_$current_time.tar.gz /home
#####################
To extract contents of compressed file, use the following syntax:
tar -xvf <file.tar.gz> <folder_name> -C <destination_directory>