Adrian Levi wrote:
> zparameters="a -mhe=on -pd1ckhead -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on 
> -si"
> zfilename="Daily Backup - $(date +"%a %h %H%M %d-%m-%Y").$backuplevel.tar.7z"

Yuck!  Look at all of those spaces in the filename!  :-)
(Recalling all of the discussion over the past couple of days
concerning whitespace in filenames and the problems that it causes.)

> When these two expand here:
> 
> tar $tarparameters $backuppath | 7z $zparameters $zfilename
> 
> I end up with all of the terms but the $zfilename still needs quoting
> somehow as it contains spaces, how do you fix that or do I have to
> escape all of the spaces with back ticks?

Do you really need spaces in the filename?  (Editorial remark: Unix
users always avoid putting whitespace in filenames because they are a
pain.)

You can quote the filenames like this:

  tar $tarparameters "$backuppath" | 7z $zparameters "$zfilename"

Personally I would remove the spaces.  And I would use a date format
that will sort nicely.  I would think that by date would be good enough.

  zfilename="backup.$(date +"%F").$backuplevel.tar.7z"
or with the time too
  zfilename="backup.$(date +"%F.%T").$backuplevel.tar.7z"

By using "%a %h %H%M %d-%m-%Y" (e.g. Fri Jan 0455 14-01-2011) and
putting the day of the week first it means that the collation order
will be by day of the week.  Personally I wouldn't care for that
ordering.  Instead I would order it %F (e.g. 2011-01-14) so that it
will be arranged by time.

Bob

Attachment: signature.asc
Description: Digital signature

Reply via email to