Sponsored Content
Full Discussion: Back up log files using tar
Top Forums Shell Programming and Scripting Back up log files using tar Post 302903658 by Aia on Wednesday 28th of May 2014 09:35:29 PM
Old 05-28-2014
Quote:
Originally Posted by karthikk0508
Hi Aia,

I did write a piece of code but not quite confident with it as I m not entirely into coding...but nt really sure if I had put it together exactly right..
[...]
It is troublesome to solicit and use other people's code without having knowledge of what it is.

Unfortunately, there was not much in what you posted to work with, it just helped me to use the specific path and timestamp to hard code in my snippet.

You have to have installed the perl module Archive::Tar from CPAN or from your distro repo.

Code:
#!/usr/bin/perl

# Author: Aia
# Date: 5/28/2014
# perl_tar.pl
# No guaranties that this will work or that it will not destroy your data

use strict;
use warnings;
use Archive::Tar;

my @file_list = glob "/apps/XEServer/*.log";
my $dir = "/apps/XEServer";

my @now = localtime;
my $date = sprintf("%02d%02d%02d", $now[5]+1900, $now[4]+1, $now[3]);

my $tar_job = Archive::Tar->new();
$tar_job->add_files(@file_list);
$tar_job->write("backup/backup_$date.tar");

# un-comment this line below if you feel confident and want to delete any original file used to make the tar
#unlink @files_list;


Last edited by Aia; 05-28-2014 at 10:55 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bring back removed files

Dear People I have removed some of my files and directories( by using rm and rmdir commands) by mistake. I wish to bring them back. How is it possible?( I am using solaris 2.6) best regards Reza Nazarian:( (2 Replies)
Discussion started by: Reza Nazarian
2 Replies

2. UNIX for Dummies Questions & Answers

tar to tape and back

Howdy, I'm trying to tar some directories to tape and then extract them from tape on another machine. I was hoping someone could help me with the syntax of the tar commands. Both machines are running Solaris 8. Need to get all files and directories under the following: ... (6 Replies)
Discussion started by: pmetal
6 Replies

3. UNIX for Advanced & Expert Users

Untaring *.tar.tar files

Hi all, How to untar a file with .tar.tar extension. A utility that i downloaded from net had this extension. Thanks in advance, bubeshj. (6 Replies)
Discussion started by: bubeshj
6 Replies

4. Filesystems, Disks and Memory

Can I back up all the files I work with each day using tar?

Can I back up all the files I work with each day using tar? (2 Replies)
Discussion started by: jo calamine
2 Replies

5. Shell Programming and Scripting

Script to tar up old log files

Hell All! I need help writing a script for my job. I never really wrote alot of scripts but I guess it a first time for everything. I need to write a simple script that goes out to our log file directory on our servers and tar and compress them. I need to know how to add an date time stamp to tell... (5 Replies)
Discussion started by: aojmoj
5 Replies

6. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

7. UNIX for Dummies Questions & Answers

how to get my files back..

hi all using unix (hp-ux) i created patches Directory under /tmp ... inside the /tmp, i fired these commands: # mv patch_file1 /patches # mv patch_file2 /patches there was no error then i realized that this command will move the files to patches Dir on the root which was NOT... (2 Replies)
Discussion started by: neemoze
2 Replies

8. UNIX for Advanced & Expert Users

Back up of recent modified files

Hi, I want to identify the files that are recently modified or with in a specified period (15 Days) in UNIX box. After identifying the files should be transferred to windows machine through FTP. The files should be overwritten in windows if it is already available. Please help... (1 Reply)
Discussion started by: lathish
1 Replies

9. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

10. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies
strclean(1M)															      strclean(1M)

NAME
strclean - remove outdated STREAMS error log files SYNOPSIS
logdir] age] DESCRIPTION
cleans the STREAMS error logger directory of log files mm-dd) that contain error messages sent by the STREAMS log driver, strlog(7). If the option is not used to specify another directory, removes error log files in the directory. If the option is not used to specify another age, removes error log files that have not been modified in three days. Options recognizes the following options and command-line arguments: Specifies a directory for the location of the STREAMS error log files to be removed if this is not the default directory Specifies a maximum age in days for the STREAMS error log files if this not the default age of 3. The value of age must be an integer greater than or less than 3. EXAMPLES
Remove day-old error log files from a directory called FILES
One or more error log file or files on which operates. The mm-dd in the filename indicates the month and day of the messages con- tained in the file. NLS catalog for SEE ALSO
strerr(1M), strlog(7). strclean(1M)
All times are GMT -4. The time now is 12:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy