need some help with muli-volume tar (ubuntu, bash, gnu tar)
I'm working on creating a routine backup scheme and am having a problem with creating a multi-volume backup with GNU tar 1.15 included with the Ubuntu 6.06 Linux distro.
First I'd like to start with just using tar to create a full backup. My destination device is either an external USB connected hard disk, or a samba file share. The destination file system is FAT (2G limit!). My goal is to do a full backup of the file system in 2G tarballs, with a sequential number as part of the filename. I run the following command as root: tar -c -v -p -M -L 2097152 -f '/media/usbdisk/fullbackup' -X '/media/usbdisk/backup.exclude' --info-script='/media/usbdisk/backup.nextvol' / I'm having a problem getting the --info-script. It successfully launches the script, but I have no idea how to communicate between tar and the script. The documentation on gnu.org shows a sh script example, but I'm using the bash shell. Unfortunately, the example doesn't work in bash - the "file descriptor 3 (>&3)" seems to be invalid, and I don't see the tar environment variables. I've created a dummy script that lists out the environment variables (a "set" command) and there do not appear any TAR_* environment variables. I'm not yet a bash/tar/*nix guru, so that could be the problem. Is anyone out there smart enough to solve the problem? Thanks, Matt |
In the original script that you're using as a template, is the
descriptor being defined somewhere above the line where it's being used in the way you're trying to use it? Basically bash is a super-set of bourne, and pretty downwards compatible. Cheers, Tink |
Thanks for the help.
Interesting. The descriptors are not declared in the info-script called from tar. I'm not sure what you mean, though. Here's the script: Code:
#! /bin/sh I actually took a different approach. I gave up on trying to get tar multi-volume to work and just piped tar to the split command. I think might be a better approach because it also allows me to use the bzip2 to compress the backup (whereas tar multi-volumes do not). so, here's the command I went with: Code:
tar -c -v -p -j -X '/media/usbdisk/backup/backup.exclude' / | split -d -b 1999m - /media/usbdisk/backup/fullbackup.tar.bz2. However, I'm interested in the tar multi-volume info-script puzzle if anyone knows the answer. This whole defining the descriptor thing sound like a lesson for me. |
Well, I've never used more file-descriptors than the 3 bash provides
by default, but my understanding is that use another one you'd need to tie it to a file of sorts, e.g. exec n>some-file That's what happens in configure scripts all the time. I'd guess that the shell (without such methods) wouldn't know what to do with the data that you then try to redirect to 3. In addition to that: multi-volume tar was originally meant for tapes and the likes, where you actually swap the device over when the first one is filled up, hence there was no need for any scripting at the end. But I like the theory, and will examine it ;} Cheers, Tink |
A response from the help-tar gnu mailing list tells me that the lack of $TAR_* variables is likely due to the fact that I'm using an older version of tar (1.15.1 installed with ubuntu 6.06) than 1.15.90, which is what is documented online.
So, I think that solves the mystery. If I'm to use the multi-volume support and info-script, my script would have to rename the archive file just created, instead of specifying the name of the next archive file. Code:
#/bin/sh |
All times are GMT -5. The time now is 12:45 AM. |