Re: [Hampshire] Finding files not used in the last 365 days

Top Page

Reply to this message
Author: Brian Chivers
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Finding files not used in the last 365 days
Tim B - Systems wrote:
> Would something like this help?
>
> # /bin/bash
>
> for a in `find ./ -mtime 10`
> do
> echo "cp $a <destination>/$a"
> done
>
> find files younger than 10 days old and print out the command to copy them.
> This script does not like spaces in filenames.
>
> Tim B.
>
> On Tuesday 08 May 2007 12:00, Brian Chivers wrote:
>> I've just finished building a new server for our Admin staff but I don't
>> really want to copy over all the data as a lot of it is really old.
>>
>> What I'd like to do is to move all the old stuff onto one of our less used
>> servers or even an external HDD so we have it as an archive.
>>
>> The directory structure is something like this
>>
>> /home/admin/Marketing/xxxxxxxxxxxxx
>>
>> where xxxxxxxxxxxx is all the subdirectories & files that I'd like to move.
>> It's more the files I'd like to move.
>>
>> I've worked out that I can use the "find" command with -mtine 365 extension
>> but what I don't know how to do is the actual moving the files but
>> maintaining the directory structure on the archive so something move them
>> to something like
>>
>> /mount/achieve/Marketing/xxxxxxxxxxxxxx
>>
>> where xxxxxxxxxxxx is a duplicate of the directory structure that it's been
>> moved from.
>>
>> Does this make sense ??
>> Brian
>>
>> ---------------------------------------------------------------------------
>> --------------------- The views expressed here are my own and not
>> necessarily
>>
>>                 the views of Portsmouth College

>


For testing I went with Tim's little script but slightly altered to work with spaces.

Here's the script

#!/bin/bash

find /home/admin/Marketing/ -atime +365 | while read FILE
do
      echo "cp $FILE /mount/archieve$FILE" >> oldfiles.txt
done


So now I have a text file that I can either chmod 700 to cp the files or compare to the output of
Hugo's script and create some horrible monster of a script :-)

Brian


------------------------------------------------------------------------------------------------
    The views expressed here are my own and not necessarily


                the views of Portsmouth College