Remove files from tar archive which are more than 1000 days old.
I am not able to extract/remove files older than 1000 days from a tar archive in linux system.
Above is my code to create a tar file. We run this script every end of day to archive the files in directory /home/x/tmp/ Also, I have another requirement to purge files from this tar which are 1000 days older. My doubt is, how to find out the files in the tar archive which are older than 1000 days.
Please advise the optimal solution to achieve this. Appreciate your solutions.
Thanks in advance
The very first problem is that you do not create a relative tar archives:
You did this:
Instead of this
Note the leading red dot.
To do what you ask, one way to do this extract a relative tar archive to some harmless disk somewhere, delete the file(s) you no longer want, then rebuild the archive. Note that most places do not do things this way, it is very cumbersome. Rather, there is a backup plan, and incremental backups made, say every day of the month. A full back up is made at month end. Then last month's incrementals are overwritten day by day.
You keep the month end backups and one month of incremental backups. We cycle on a 90-day basis, not 30.
If you had relative tar files (you don't) you could try something like this:
I cant seem to work out how to count the number of executable files in a particular tar archive? Only in a directory as a whole.
I also cant work out how to count number of certain file types in a tar archive. Only the directory, pretty stuck :( (9 Replies)
I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also?
I found one command which is to create gz file for the... (4 Replies)
Hi all. Here's my situation:
I have performance reports that run every 30 minutes saved in the format:
stats_report_11251000.txt
stats_report_11251030.txt
stats_report_11251100.txt
stats_report_11251130.txt
(Obviously run at Nov 25 10 AM, 10:30 AM, 11 AM and so on...)
I would... (2 Replies)
Hi Folks,
I have a tar.gz compressed file with me, and I want to know the number of files in the archive without uncompressing it.
Please let me know how I can achieve it.
Regards
RK Veluvali (5 Replies)
Hi,
I'm Eddy from Belgium and I've the following problem.
I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands.
The problem is that I do not find a good combination... (4 Replies)
Hello,
I need help in finding files older than x days and creating a single consolidated tar file combining them. Can anyone please provide me a script?
Thanks,
Dawn (3 Replies)
Hi,
I need to create recursive tar archive, while I put there only files of type a*.txt.
Without file filtering the command is: tar cfzf test.tar.gz test_tar/
How I include the switch for including only files with pattern a*.txt ?
Thanks a lot! (1 Reply)
Hi, I would modify to delete the files after creating the tar archive.
How I can modify the following command:
tar -cvvf logswitch.tar `find *.log* -mtime +5`
It create a tar with files that are older than 5 days. (5 Replies)
Hello,
I have a tar archive full of compressed .Z (compressed with the compress command) files. I have restored the tar to a disk but am looking for a way to uncompress every file in every sub-directory. Under normal circumstances, I would just change directories and "uncompress *" but with 1600... (3 Replies)
Hi there,
I am trying to tar a number of files held in a specific folder. I am only interested in archiving files older than 30 days. Having read through the man entries and all available documentation I thought I'd cracked the coomand with
tar -c -z -v -N 15/04/2004 -f /wfch.tar *
This... (6 Replies)