Tar archive problems.

Dale Farnsworth dale at farnsworth.org
Sun Oct 28 21:58:04 MST 2007


Nathan wrote:
> 
> I have a set of files that are lists of files in my filesystem. I run backups 
> against these scripts doing something like this...
> 
> #!/bin/bash
> copy_contents() {
> (tar -cpf - "$i" | tar -f - -xpC /tmp/filearchive.1)
> }
> 
> while read i ; do
>       if ! [ -d "$i" -a -e "$i" ]; then
>          copy_contents 1>/dev/null 2>/dev/null
>       fi
>       done < file_list.1
> 
> It works great, but I have several empty directories that are not backed up, 
> but I would like them to be backed up as files go in them temporarily, but I 
> have to manually add those empty directories. How can I do the above but 
> include the empty directories?

I'd use:

while read i
do
	cp -ax "$i" /tmp/filearchive.1
done < file_list.1

You may not want the -x option to cp.

-Dale


More information about the PLUG-discuss mailing list