Keeping oldest backup files?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Keeping oldest backup files?
# 1  
Old 06-26-2013
Tools Keeping oldest backup files?

I need a script to clean up the files on our backup system. I was hoping this would be simple for someone to put together for me.

I'm sure I could do it, but I'm a bash n00b so it would definitely not be efficiently or within a reasonable amount of time. Smilie

Requirements:
- Root of backups is at /var/backup
- We are to process any directory whose name matches "vid*", "pic*", "usr*","*bak", "*.bak". Ignore any other directories.
- Each directory is processed individually.
- We don't recurse into lower directories.
- We only want to process files whose name matches "*config", "*_bak", "*.cfg". Ignore any other files.
- Delete any file matching "*.tmp" that is older than 30 days.

For each matching directory we will:
- Identify the oldest file that matches the above file name requirements
- Compare the content of that file to all other files that match the file name requirements and delete any matches.
- Identify the next newest file that remains
- Repeat the process until all duplicates are removed.
- Finally delete any "*.tmp" files that are older than 30 days.

ALL HELP IS APPRECIATED!
# 2  
Old 06-26-2013
In here, certainly nobody will "put together for you" a script. Search these fora (this topic has been covered umpteen times), put sth together yourself, and we'll be glad to help debug/improve.
# 3  
Old 06-27-2013
try the best possible usage of find command. It will be the best possible help for u..
# 4  
Old 06-27-2013
Quote:
Originally Posted by mritusmoi
try the best possible usage of find command. It will be the best possible help for u..
Thanks. I'll start scouring the man page now.

Quote:
Originally Posted by RudiC
In here, certainly nobody will "put together for you" a script. Search these fora (this topic has been covered umpteen times), put sth together yourself, and we'll be glad to help debug/improve.
I don't expect anyone to write a complete script for me. I can get the logic down for what I need, and cobble something together. I'm just hoping to get some pointers on what commands would be best to accomplish this task.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Merge 4 bim files by keeping only the overlapping variants (unique rs values )

Dear community, I am facing a problem and I kindly ask your help: I have 4 different data sets consisted from 3 different types of array. On each file, column 1 is chromosome position, column 2 is SNP id etc... Lets say I have the following (bim) datasets: x2014: 1 rs3094315... (4 Replies)
Discussion started by: fondan
4 Replies

2. Shell Programming and Scripting

Delete 3 oldest files

Trying to delete my 3 oldest files. I am learning despite the many questions. This shows the files. ls -1r /media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/Ubuntu_Documents.zip_* | tail -n+6adding this on did not work. | -exec rm {}------ Post updated at 05:43 PM ------ This works, but I... (15 Replies)
Discussion started by: drew77
15 Replies

3. UNIX for Advanced & Expert Users

Finding oldest files

There are some 25,000 files in 7,000 directories in my source library and I am trying to find oldest files. I am running this find: find /usr/mysrc -name "*." -type f -mtime +8000 -exec ls -l {} 2>/dev/null and playing with the days parameter for mtime, but the output is not sorted... (3 Replies)
Discussion started by: migurus
3 Replies

4. Shell Programming and Scripting

Parallel move keeping folder structure along with files in it

The below will move all the files in the directory dir to the destination using parallel and create a log, however will not keep them in the directory. I have tried mkdir -p but that does not seem to work or at least I can not seem to get it (as it deletes others files when I use it). What is the... (2 Replies)
Discussion started by: cmccabe
2 Replies

5. UNIX for Dummies Questions & Answers

Copy files from one drive to another, keeping most recently modified files

Hi all, I am a bit of a beginner with shell scripting.. What I want to do is merge two drives, for example moving all data from X to Y. If a file in X doesn't exist in Y, it will be moved there. If a file in X also exists in Y, the most recently modified file will be moved to (or kept) in... (5 Replies)
Discussion started by: apocolapse
5 Replies

6. Shell Programming and Scripting

Archiving files keeping the same structure directory

Hello Team, We would like to backup a lot of files inside of a structure of directories, four, five or more levels in some Ubuntu, Mac and Solaris systems. For instance: /home/chuck/sales/virgin/rent-quote.pdf /home/chuck/sales/marriott/vacation-quote.pdf... (2 Replies)
Discussion started by: csierra
2 Replies

7. Shell Programming and Scripting

Moving files only by oldest file one at a time

Hi I am want to create a script where the file gets moved from the current folder to a folder transfer based on the oldest first. This script should run one file at a time using a loop. I want it as a loop because I want to do some processing while I have one file. Can anyone guide me on this? (2 Replies)
Discussion started by: chamajid
2 Replies

8. Shell Programming and Scripting

copying unreference files and keeping absolute path

Hi guys, I'm creating a script that basically remove unreference files so at the moment I have something like: DAYS=30 for DIRECTORY in `mount | awk '{ print $7}'` do find $DIRECTORY -type f -atime +$DAYS < ~/files.log done for FILE in `awk '{print $1}' ~/files.log` do cp... (2 Replies)
Discussion started by: hariza
2 Replies

9. Shell Programming and Scripting

sort files by date, delete oldest, if total size bigger than

hello people i need your help please i want to achieve the following with the simplest, most efficient shell-tools: i have a directory with a lot of files from users. the script should check which partition the dir is on if the partition with the directory is more than 90% full ... (2 Replies)
Discussion started by: scarfake
2 Replies

10. Shell Programming and Scripting

Oldest files

Anyone know of a way to list all of the files including subdirectories and list them as oldest first? (2 Replies)
Discussion started by: 2dumb
2 Replies
Login or Register to Ask a Question