Hello fellow Linux supporters!
I apologise if this specific thread is off topic to this mailing list.
I've been having problems with a backup script and am not sure how to make this work.
So far, Mr. Google hasn't helped me much -- maybe my search terms have been as dumb as I'm feeling right now.
The script will take files or dirs as parameters and will back them up in a presefined location, using tar. Problems arise when it will encounter files or directories which contain spaces in their names.
Would anyone be kind enough to tell me where I went wrong with my approach?
Script is below:
#Init stuff DATETIME=`date +%Y_%m_%d.%H_%M` BK_LOCATION="/mnt/work/backup/"
#Test parameters. If dirs and files do exist, add them to a list # that will be used as parameters for the tar command.
for PARAM in "$@";
if [ -d "$PARAM" ];
then #is it an existing directory?
if [ -f "$PARAM" ]; then #is it an existing file?
if [ ! -n "$BK_LIST" ];
else #this else branch exists for debugging purposes
echo "You have chosen to backup: $BK_LIST"
tar -cjf $BK_FULLPATH $BK_LIST
Sent from my Brick (TM)