gctaylor1 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to piece it together one step at a time and so far this is all I can get working:
If I try adding things like --exclude-from=$localdir I get various errors depending on where I put the--exclude-from.my @args = ("/bin/tar", "czvf", $storageLocation.$archiveName, $arc +hiveDir ); system(@args) == 0 or die "system @args failed: $?";
Here's the line from the working bash script I'm trying to copy.
At this point I haven't tried to get the other options working as I thought this would be the simplest. I suspect piping the output to ssh will be a challenge as well and am saving that for last.tar -czvf - -g $BACKEDUP --index-file $INDEXFILE --exclude-from $MYEX +CLUDES --totals /home/user1/ | ssh remote_machine "cat > /mnt/mount_p +oint/dir1/$FILENAME"
In the process of trying to get this working with system() I wondered if I should really be using Archive::Tar and Net::SSH::Perl? My primary reason for using the OS provided tar and ssh is that I thought it would be simpler and provides behavior that I'm familiar with. Then once I had this working I could switch to the more complex(?) task of using Archive::Tar and Net::SSH:Perl.
Any advice or pointers?
And to keep this all in perspective, I'm doing this project for learning purposes. I've been working my way through Perl books but am tired of doing exercises and want something useful to do.
Here's the full script:
Which produces the error:#!/usr/bin/perl use strict; use warnings; my $excludes = "/home/user1/scripts/perl/backup/excluded_files.txt"; my $storageLocation = "/mnt/mount_point/dir1/"; my $archiveName = "backup.tar.gz"; my $archiveDir = "/home/user1/temp"; my @args = ("/bin/tar", "czv --exclude-from=$excludes -f", $storageL +ocation.$archiveName, $archiveDir ); system(@args) == 0 or die "system @args failed: $?";
/bin/tar: Old option `b' requires an argument. Try `/bin/tar --help' or `/bin/tar --usage' for more information. system /bin/tar czv --exclude-from=/home/user1/scripts/perl/backup/excluded_files.txt -f /mnt/mount_point/dir1/backup.tar.gz /home/user1/temp failed: 5 12 at /tmp/filename.pl line 12.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Error using system() and tar with several options
by Crackers2 (Parson) on Apr 13, 2009 at 21:38 UTC | |
Re: Error using system() and tar with several options
by Tanktalus (Canon) on Apr 13, 2009 at 21:36 UTC | |
Re: Error using system() and tar with several options
by linuxer (Curate) on Apr 13, 2009 at 21:34 UTC | |
Re: Error using system() and tar with several options
by gctaylor1 (Hermit) on Apr 13, 2009 at 23:36 UTC | |
Re: Error using system() and tar with several options
by Utilitarian (Vicar) on Apr 14, 2009 at 09:04 UTC | |
by gctaylor1 (Hermit) on Apr 14, 2009 at 19:59 UTC |