[lug] I need help from a bash scripting guru

Bruce Raup brauplists at gmail.com
Sun Jan 6 22:01:58 MST 2008


Paul,

I don't know the direct answer to your question, but have you looked
into rsync to do the backups?  It might obviate your current problem,
as it produces lists of files it copies.

Bruce

On Jan 6, 2008 5:17 PM, Paul E Condon <pecondon at mesanetworks.net> wrote:
> I'm working on a file backup script that has a feature
> of my own design. I have written a script that uses
>
>   cp -au --backup=t <srcdirpath> <backupdirpath>
>
> for the bulk of the work. With these options
> (particularly --backup=t) all old versions of files that
> change are preserved in the backup.
>
> I like this for grabbing clean copies of things that I
> have accidentally clobbered. But I wanted more ---
>
> I also wrote a few lines that check if a file has been
> deleted from the source and writes, for such file, a
> record into the backup giving the time/date when a
> backup process first noticed that the file was missing.
>
> To do this, I produce two files of the names of files
> in both the source using
>
> find . -type f | sort > <filenamelist>
>
> to create a sorted list of file names for source and
> backup and then use
>
> join -j 1 -v 2 <sourcelist> <backuplist> >missinglist
>
> ( the -v 2 writes records from the second input that don't
> join to any record from the first input)
>
> This works fine so long as there are no spaces in any of the file
> names.  Now I want to make it work for spaces and general garbage in
> the file name. I have almost a solution: with -t \` added to the join
> command, the accent-grave, or 'back-quote' character becomes the field
> delimiter in join. This works fine so long as there are no back-quotes
> in any of the file names, and there aren't any --- so far. But I'd
> like a more bullet proof solution.
>
> Is there some way to tell join to use, for example, the line-feed
> character as field delimiter? Or some other character which should
> never appear in proper file names under UNIX, or Mac OSX, as
> implemented by netatalk, or Windows names as handled by Samba? Put
> another way - Is there one character that never appears in file names
> of all these OSs, and can be introduced as the field delimiter into
> GNU join?
>
> TIA
> --
> Paul E Condon
> pecondon at mesanetworks.net
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>



-- 
Bruce Raup
http://cires.colorado.edu/~braup/



More information about the LUG mailing list