I've written my first bash script for backing up my music album by album onto an external FAT32 drive.
# Music collection backup script
# Each album folder goes into one tar.gz file in target location (because of 4gb limit in fat32)
# Each album added is appended to album_list - simple text file in target dir
# Gzipping is a waste of time. The gain over mp3 compression is negilible
for album in *
if [ -f $backup_dir/"$album" ]
echo $album is already backed up
tar -cf $backup_dir/"$album" "$album"
echo $album >> $album_list
It generally works as expected even with filenames full of spaces. My problem lies with albums with ':' characters in the title:
Which give the following error:
tar: /media/IOMEGA_HDD/linux_backup/music_collection/Mogwai-Government Commissions\: BBC Sessions 1996-2003: Cannot open: Invalid argument
It's nothing to do with the file length. I wonder if enclosing in "" doesn't allow you to escape two non-standard characters in a row?
Any ideas? I'd rather not change all my filenames, because I'd rather a robust script that works with a variety of stuff.