LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar the last periodic backup that is in another path and move the tar to some dir (https://www.linuxquestions.org/questions/linux-newbie-8/tar-the-last-periodic-backup-that-is-in-another-path-and-move-the-tar-to-some-dir-924274/)

nelovicov 01-17-2012 12:26 PM

tar the last periodic backup that is in another path and move the tar to some dir
 
I want to make a script that have to take "get or mv" the tar file from another path. The script make a tar of the last periodic backup (PB). The PB have the same name with diferent date. When the script find the last PB make a tar and move the tar file in other path. Could some one help, please?

repo 01-17-2012 12:30 PM

Hi,

Show us what you have written already, and where you are stuck.

Kind regards

nelovicov 01-17-2012 12:54 PM

For this part I haven't nothing, 'cause I have three machine. I take archives in one to put in another, 2nd one, for this I use a perl script. Then I want to take the periodic backup and put this in the same dir with the archives that came from 1st machine. Then I'll make a tar of this dir and put in the 3rd machine. I just make an experience using "find -mtime", but is not what I looking for.

$ftp = Net::FTP->new($ftp_server1, Passive => 1) or die "unable to connect: $@\n";
$ftp->login($ftp_uid1, $ftp_pw1) or die "unable to login: $@\n";
$ftp->cwd($ftp_dir) or die "Cannot change working directory ", $ftp->message;
$ftp->binary;

$ftp->get($ftp_file1) or die "Cannot list directory ", $ftp->message;
$ftp->get($ftp_file2) or die "Cannot list directory ", $ftp->message;

$ftp->quit;

chrism01 01-17-2012 11:43 PM

Well, that code looks basically ok; what happens when you run it?
Obviously it needs some code to get/set vars first, but just to test you can hardcode them.

nelovicov 01-19-2012 08:12 AM

I didn't put all the code. but I set vars first. But this script is only to get the files there need to put in the 2nd machine using FTP. Now I want to tar the last periodic backup and move it to some directory. Could some one help. how can I do it?

chrism01 01-19-2012 05:24 PM

If you want to do it purely in Perl, try this module http://search.cpan.org/~bingos/Archi...Archive/Tar.pm
Otherwise, you could make an external call with qx or system http://perldoc.perl.org/perlop.html#...Like-Operators or try open2 & open3 http://perldoc.perl.org/IPC/Open2.html or try 'piped open' http://perldoc.perl.org/perlipc.html...%28%29-for-IPC

nelovicov 01-20-2012 09:40 AM

no, I don't want to make it using perl, I want to use shell script, 'cause my machine is using an old solaris version and in perl archives I don't have the tar.pm... I made a download of it and put it in the right directory, but is not working...


All times are GMT -5. The time now is 04:00 PM.