Backup_Directory="/media/andy/Maxtor/Backup/Ubuntu_Mate_24.04/"
.
.
.
#
cd /etc/hosts
tar -cvf hosts.tar hosts
/usr/bin/rsync --progress -r -u hosts.tar $Backup_Directory
/home/andy/bin/Backup_24_04.sh: line 46: cd: /etc/hosts: Not a directory
tar: hosts: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Added the backslash. Now I get an empty tar file.
cd /etc/hosts/
tar -cvf hosts.tar hosts
/usr/bin/rsync --progress -r -u hosts.tar $Backup_Directory
/etc/hosts is a (text) file named hosts that is located in the /etc directory and not a directory itself. So, it's natural that you're getting that cd: /etc/hosts: Not a directory error.
Given that /etc/hosts is a single file, do you have any reason to want to add it to a ".tar" file? If not, you could simply copy that file to the Backup Directory with the following command.
Given that /etc/hosts is a single file, do you have any reason to want to add it to a ".tar" file? If not, you could simply copy that file to the Backup Directory with the following command.