Sponsored Content
Full Discussion: Exclude certain folders
Top Forums Shell Programming and Scripting Exclude certain folders Post 302912034 by arumugavelvelu on Tuesday 5th of August 2014 10:53:35 AM
Old 08-05-2014
Exclude certain folders

Hi Experts,
Below is my shell script and it will move the files older than 90 days to archive mount. Now my new requirement is , I need to move some of the directory files older than 365 days. How can I achieve this.

Simply I have
DIR1
DIR2
DIR3
DIR4
I need to exclude DIR 2 and DIR 2 directory older than 365 days files should be moved to another directory. Remaining directory will move the files older than 90 days as usual
Code:
#!/bin/ksh
#
#
# Backup Script to move older than 90 days files
DATE=`date +%Y%m%d`
#
#SRC Directories and Location
#-----------------------------------------------------
SRC_CDR_OUTBOUND=/omount/outbound
SRC_CDR_INBOUND=/omount/inbound
DEST_SRC_BILG=/omount/archive/
#-----------------------------------------------------
#
DATE=`date +%Y%m%d`
#Counting Number of files
#--------------------------------------------------------
BK_FILECOUNT_OUT=`find $SRC_CDR_OUTBOUND -type f -mtime +90 |wc -l`
BK_FILECOUNT_IN=`find $SRC_CDR_INBOUND -type f -mtime +90 |wc -l`
#--------------------------------------------------------
#
#Finding OUTBOUND files older than "90" days and Move the files to archive folder
#-----------------------------------------------------------------------------
find $SRC_CDR_OUTBOUND -type d -name '*' -exec mkdir -p $DEST_SRC_BILG{} \;
find $SRC_CDR_OUTBOUND -type f -name '*' -mtime +90 -exec mv {} $DEST_SRC_BILG{} \;
#-----------------------------------------------------------------------------
#
#Finding INBOUND files older than "90" days and Move the files to archive folder
#-----------------------------------------------------------------------------
find $SRC_CDR_INBOUND -type d -name '*' -exec mkdir -p $DEST_SRC_BILG{} \;
find $SRC_CDR_INBOUND -type f -name '*' -mtime +90 -exec mv {} $DEST_SRC_BILG{} \;
#-----------------------------------------------------------------------------
#Generating the log with date and file count for refernece
#-------------------------------------------------------------------------------------------
echo $BK_FILECOUNT_OUT "Outbound files moved to archive on"$DATE >>/omount/backup_logs.txt
echo $BK_FILECOUNT_IN "Inbound files moved to archive on"$DATE >>/omount/backup_logs.txt
#-------------------------------------------------------------------------------------------

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by vbe; 08-05-2014 at 12:43 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Backing up Folders without some folders...;)

I am in a fix....... I have to write a backup script to backup say Folder A. Folder A contains n folders 1,2 ,3 .....n. my script should copy A without folder 2 & 3. Is there anyway I can do it without writing individual copy commands???? Please help.... (1 Reply)
Discussion started by: chimpu
1 Replies

2. UNIX for Dummies Questions & Answers

Copying Folders without some folders... ;-)

I am in a fix....... I have to write a backup script to backup say Folder A. Folder A contains n folders 1,2 ,3 .....n. my script should copy A without folder 2 & 3. Is there anyway I can do it without writing individual copy commands???? Please help.... (5 Replies)
Discussion started by: chimpu
5 Replies

3. Shell Programming and Scripting

How to exclude folders/files in search?

I have a directory with about 20 folders and many different types of files. I need to search for files and gzip in all the directories except for 1 directory. How do you exclude a directory? (2 Replies)
Discussion started by: bbbngowc
2 Replies

4. Shell Programming and Scripting

Making 99 folders 99 folders deep

I am trying to make a unix shell script that will make 99 folders 99 deep (counting the first level folders). So far i have made it make the first 99 folders and 99 more in all of the folders. The only problem is the only way i have found is copying and pasting part of the script over and over and... (18 Replies)
Discussion started by: YukonAppleGeek
18 Replies

5. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

6. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

7. Shell Programming and Scripting

Grep for a srting & exclude two folders

Hi, Below is the command to grep for a string under grep -r "redeem" /home/tom Need to make it case insensitive and exclude logs & tmp folders under /home/tom directory in my Search. Need this in Linux. (1 Reply)
Discussion started by: mohtashims
1 Replies

8. Shell Programming and Scripting

Copy between two different folders containing same sub-folders

I have a folder like this ls input1 dir1 dir2 dir3 file1 file2 file3 dir1, dir2 and dir3 are sub-folders inside the folder input1 ls input2 dir1 dir2 dir3 file1 file2 file3 My dir1 in input1 folder has files f1, f2, f3 and f4. My dir1 in input2 folder has file f4 and f5. ... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

9. UNIX for Dummies Questions & Answers

Archive folders and sub folders

Hi Can i archive folder and folders in with the tar command My files are located in subfolders Eg: Folder1/Folder1_1/*.pdf Folder1/Folder1_2/*.pdf Folder1/Folder1_3/*.pdf so i would like to tar all the files in Folder1_1 and Folder1_2 only not Folder1_3 that should be done next... (2 Replies)
Discussion started by: cnrj
2 Replies

10. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies
BF_TAR(1)																 BF_TAR(1)

NAME
bf_tar - shell script to write a tar file of a bogofilter directory to stdout SYNOPSIS
bf_tar [-r] [-R] bogofilter_directory DESCRIPTION
bf_tar bundles a bogofilter working directory in tar format and copies it to standard output (your console, or where you redirect it, see EXAMPLES below). OPTIONS
The -r option causes bf_tar to remove inactive log files after the archive has been written successfully. The default is to leave log files. The -R option causes bf_tar to remove inactive log files before the archive is written. This may reduce chances that the resulting archive is recoverable should it become damaged. The archive may be smaller though. The default is to leave log files. EXIT STATUS
The script exits with status code 0 if everything went well, and nonzero if it encountered trouble. EXAMPLES
o bf_tar ~/.bogofilter > outfile.tar Writes a standard .tar file containing the essential files from ~/.bogofilter to outfile.tar. o bf_tar ~/.bogofilter | gzip -9 -c > outfile.tar.gz Writes a gzipped .tar.gz file containing the essential files from ~/.bogofilter to outfile.tar.gz. o bf_tar `pwd`/mydirectory > outfile.tar Prepend $(pwd)/ or `pwd`/ if you want to specify an absolute path instead of a relative path. NOTES
This script is meant for use with Berkeley DB based bogofilter versions. This script requires a SUSv2 compliant pax utility. This script expects a SUSv2 compliant shell. Solaris systems should have the SUNWxcu4 package installed (when bogofilter is configured) so that /usr/xpg4/bin/sh can be used. 07/23/2007 BF_TAR(1)
All times are GMT -4. The time now is 12:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy