Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
06-03-2006, 08:44 AM
|
#1
|
|
LQ Newbie
Registered: Jun 2006
Location: Atlanta, GA
Distribution: Ubuntu 6.06
Posts: 4
Rep:
|
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
|
|
|
|
06-04-2006, 01:09 AM
|
#2
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
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
|
|
|
|
06-04-2006, 09:16 AM
|
#3
|
|
LQ Newbie
Registered: Jun 2006
Location: Atlanta, GA
Distribution: Ubuntu 6.06
Posts: 4
Original Poster
Rep:
|
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
echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
# name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
case $TAR_SUBCOMMAND in
-c) ;;
-d|-x|-t) test -r ${name:-$TAR_ARCHIVE}-$TAR_VOLUME || exit 1
;;
*) exit 1
esac
echo ${name:-$TAR_ARCHIVE}-$TAR_VOLUME >&3
So, when it runs, TAR_VOLUME and TAR_ARCHIVE are blank. According to Gnu tar documentation,those vairables are set when the script is called.
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.
This created a nice set of files, fullbackup.tar.bz2.00 and fullbackup.tar.bz2.01
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.
|
|
|
|
06-04-2006, 04:11 PM
|
#4
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
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
Last edited by Tinkster; 06-04-2006 at 04:13 PM.
|
|
|
|
06-05-2006, 08:15 AM
|
#5
|
|
LQ Newbie
Registered: Jun 2006
Location: Atlanta, GA
Distribution: Ubuntu 6.06
Posts: 4
Original Poster
Rep:
|
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
#
# tar writes to a file, fullbackup
a=0
while [ -e ./fullbackup*.$a ]; do
a=`expr $a \+ 1`;
done
echo renaming to fullbackup.$a
mv fullbackup fullbackup.$a
Of course, I'd want to call tar from a script that also executes this info-script to rename the final file tar creates, keeping the set in sequential order.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:08 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|