nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

shell script and cron -zipping a folder then archiving on same server

This is a discussion on shell script and cron -zipping a folder then archiving on same server within the Shell scripting forums, part of the Development/Scripting category; First of all thank you for the reply. I should try and make out what I am trying to achieve ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 12-31-2008, 03:38 PM
Junior Member
User
 
Join Date: Nov 2008
OS: Debian
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
amanuensis is on a distinguished road
Default

First of all thank you for the reply.
I should try and make out what I am trying to achieve a little clearer.
I have a folder on my server named 'EVENTS' and it contains an additional 50 folders 'EVENT1', 'EVENT2', 'EVENTS3 etc, etc. Each of these 50 folders contains within them a varying amount of files and folders also. (So that is the set up).
I am wondering if it is within the capabilities of a script to zip all folders in the 'EVENTS' folder ('EVENT1', etc) which would of course include all of the folders contained inside the 50 folders. Kind of drilling through all folders contained within the 'EVENTS' folder without having to name them all as they will be changing over time.
If this could be done (I would need a cron to run it once a day) I would need the old zip to be deleted by the new daily zip.
At all times I would have the folder structure mentioned above in place with a zipped version of every folder next to the actual folder it was a zipped version of.

So if I was speaking to the script I would say " I want you to go into every folder you find inside the 'events' folder and zip it, but you must leave the original folders that you have zipped in place and drop the zipped version of next to it, I want you then to do this every day and remove the old zip with the new one, I don't have a list of all the folders in the 'EVENTS' folder, so go into it and work your way through".

How weird is this getting, I am not the best at explaining but I think this is a little more clear.

Many thanks again for your help
Reply With Quote
  #12 (permalink)  
Old 12-31-2008, 05:08 PM
Junior Member
User
 
Join Date: Feb 2008
OS: .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
unSpawn is on a distinguished road
Default

Something like 'find /path/to/EVENTS -type d -name EVENT\* | while read DIRNAME; do find ${DIRNAME}/* -type d|while read SUBDIRNAME; do zip -r "${SUBDIRNAME}/${SUBDIRNAME//*\//}.zip" "${SUBDIRNAME}"; done; done'? Basically what I'm saying is a shell script can provide, but you have to understand scripting ;-p
Reply With Quote
  #13 (permalink)  
Old 12-31-2008, 06:16 PM
Junior Member
User
 
Join Date: Nov 2008
OS: Debian
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
amanuensis is on a distinguished road
Default

First of all thank you for the reply.
I should try and make out what I am trying to achieve a little clearer.
I have a folder on my server named 'EVENTS' and it contains an additional 50 folders 'EVENT1', 'EVENT2', 'EVENTS3 etc, etc. Each of these 50 folders contains within them a varying amount of files and folders also. (So that is the set up).
I am wondering if it is within the capabilities of a script to zip all folders in the 'EVENTS' folder ('EVENT1', etc) which would of course include all of the folders contained inside the 50 folders. Kind of drilling through all folders contained within the 'EVENTS' folder without having to name them all as they will be changing over time.
If this could be done (I would need a cron to run it once a day) I would need the old zip to be deleted by the new daily zip.
At all times I would have the folder structure mentioned above in place with a zipped version of every folder next to the actual folder it was a zipped version of.

So if I was speaking to the script I would say " I want you to go into every folder you find inside the 'events' folder and zip it, but you must leave the original folders that you have zipped in place and drop the zipped version of next to it, I want you then to do this every day and remove the old zip with the new one, I don't have a list of all the folders in the 'EVENTS' folder, so go into it and work your way through".

How weird is this getting, I am not the best at explaining but I think this is a little more clear.

Many thanks again for your help
Reply With Quote
Reply

Tags
archive , backup , linux , shell scripting , unix , zip


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Tomcat shell script cron job to restart server kasimani Shell scripting 4 05-03-2008 08:46 PM
Shell Script to Automatically Delete a File via Cron Job kakarla Shell scripting 2 01-29-2008 09:54 AM
A script for Removing all the files inside a folder and its sub folder vivekv Shell scripting 1 10-25-2007 02:44 PM
Shell script to perform operation on remote server vivekv Shell scripting 3 10-24-2007 01:10 AM
Shell script to change folder directory owner after restore marinm Shell scripting 5 01-23-2007 01:53 PM


All times are GMT +5.5. The time now is 04:58 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38