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: #!/bin/bash #Init stuff DATETIME=`date +%Y_%m_%d.%H_%M` BK_LOCATION="/mnt/work/backup/" BK_LIST="" #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 "$@"; do if [ -d "$PARAM" ]; then #is it an existing directory? BK_LIST="$BK_LIST ${PARAM}" else if [ -f "$PARAM" ]; then #is it an existing file? BK_LIST="$BK_LIST ${PARAM}" fi fi done if [ ! -n "$BK_LIST" ]; then exit 0 else #this else branch exists for debugging purposes echo "You have chosen to backup: $BK_LIST" fi BK_FULLPATH="${BK_LOCATION} BACKUP_${DATETIME}.tar.bz2" tar -cjf $BK_FULLPATH $BK_LIST --Regards, Sent from my Brick (TM)